Skip to contentSkip to conversation

media: go7007: unregister the I2C adapter on USB probe failure

PATCH New Myeonghun Pak 1 participant 1 message Sep 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: go7007: unregister the I2C adapter on USB probe failure

USB probe failures after I2C adapter registration free the backing go7007 structure without unregistering the adapter.

If i2c_adapter_online is set, unregister the adapter before releasing USB resources so that I2C client removal can still use its callbacks.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 59aea928d57f ("[media] go7007: don't continue if firmware can't be loaded")
Assisted-by OpenAI:GPT-5.6

---
Validated with an ARM64 W=1 object build and strict checkpatch. No hardware runtime or probe-failure injection testing was performed.

 drivers/media/usb/go7007/go7007-usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/usb/go7007/go7007-usb.c +2 -0
index c0cb92fa6..b2bf24d02 100644
@@ -1320,6 +1320,8 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	return 0;
 
 allocfail:
+	if (go->i2c_adapter_online)
+		i2c_del_adapter(&go->i2c_adapter);
 	go7007_usb_release(go);
 	kfree(go);
 	return -ENOMEM;