Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe/nvm: Defer xe->nvm assignment until init succeeds

Allocate and initialize the NVM structure using a local pointer and
assign it to xe->nvm only after all initialization steps succeed.

This avoids exposing a partially initialized xe->nvm and removes the
need to explicitly clear xe->nvm on error paths, simplifying error
handling and making the lifetime rules clearer.

Cc: Alexander Usyskin <alexander.usyskin@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Brian Nguyen <brian3.nguyen@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: Brian Nguyen <brian3.nguyen@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patch.msgid.link/20260120183239.2966782-8-shuicheng.lin@intel.com

authored by

Shuicheng Lin and committed by
Ashutosh Dixit
7755ed58 a3187c0c

+4 -6
+4 -6
drivers/gpu/drm/xe/xe_nvm.c
··· 133 133 if (WARN_ON(xe->nvm)) 134 134 return -EFAULT; 135 135 136 - xe->nvm = kzalloc(sizeof(*nvm), GFP_KERNEL); 137 - if (!xe->nvm) 136 + nvm = kzalloc(sizeof(*nvm), GFP_KERNEL); 137 + if (!nvm) 138 138 return -ENOMEM; 139 - 140 - nvm = xe->nvm; 141 139 142 140 nvm->writable_override = xe_nvm_writable_override(xe); 143 141 nvm->non_posted_erase = xe_nvm_non_posted_erase(xe); ··· 163 165 if (ret) { 164 166 drm_err(&xe->drm, "xe-nvm aux init failed %d\n", ret); 165 167 kfree(nvm); 166 - xe->nvm = NULL; 167 168 return ret; 168 169 } 169 170 ··· 170 173 if (ret) { 171 174 drm_err(&xe->drm, "xe-nvm aux add failed %d\n", ret); 172 175 auxiliary_device_uninit(aux_dev); 173 - xe->nvm = NULL; 174 176 return ret; 175 177 } 178 + 179 + xe->nvm = nvm; 176 180 return devm_add_action_or_reset(xe->drm.dev, xe_nvm_fini, xe); 177 181 }