Skip to content

Commit d4c3ed9

Browse files
NitinGotelucasdemarchi
authored andcommitted
drm/xe: defer free of NVM auxiliary container to device release callback
Do not kfree the intel_dg_nvm_dev in xe_nvm_fini() right after auxiliary_device_delete/uninit. The auxiliary_device embeds the device/kobject (and its name); freeing it too early can race with asynchronous device_del/udev processing and cause a use-after-free. Signed-off-by: Nitin Gote <nitin.r.gote@intel.com> Fixes: c28bfb1 ("drm/xe/nvm: add on-die non-volatile memory device") Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://lore.kernel.org/r/20250911052823.226696-1-nitin.r.gote@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 2ec2945 commit d4c3ed9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/gpu/drm/xe/xe_nvm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static const struct intel_dg_nvm_region regions[INTEL_DG_NVM_REGIONS] = {
3535

3636
static void xe_nvm_release_dev(struct device *dev)
3737
{
38+
struct auxiliary_device *aux = container_of(dev, struct auxiliary_device, dev);
39+
struct intel_dg_nvm_dev *nvm = container_of(aux, struct intel_dg_nvm_dev, aux_dev);
40+
41+
kfree(nvm);
3842
}
3943

4044
static bool xe_nvm_non_posted_erase(struct xe_device *xe)
@@ -162,6 +166,5 @@ void xe_nvm_fini(struct xe_device *xe)
162166

163167
auxiliary_device_delete(&nvm->aux_dev);
164168
auxiliary_device_uninit(&nvm->aux_dev);
165-
kfree(nvm);
166169
xe->nvm = NULL;
167170
}

0 commit comments

Comments
 (0)