intel_th: Clear dangling resource pointer in subdevice alloc error path
Subsystems (3)
PATCH 1/1 intel_th: Clear dangling resource pointer in subdevice alloc error path
When device_add() fails, intel_th_subdevice_alloc() jumps to fail_free_res which kfree()s thdev->resource but leaves the pointer dangling, then falls through to fail_put_device where put_device() triggers the .release callback intel_th_device_free() which kfree()s thdev->resource again, causing a double free.
Set thdev->resource to NULL after kfree() so the subsequent intel_th_device_free() finds a NULL pointer and skips it.
Fixes a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices")
Signed-off-by Haotian Zhang <[email protected]>
--- drivers/hwtracing/intel_th/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/intel_th/core.c +1 -0
@@ -696,6 +696,7 @@ intel_th_subdevice_alloc(struct intel_th *th, fail_free_res:kfree (thdev->resource); + thdev->resource =NULL ; fail_put_device:put_device (&thdev->dev);
Signature · 1 line
2.25.1