Skip to contentSkip to conversation

media: cx231xx: Fix cleanup path on failure

PATCH New Andi Shyti 1 participant 1 message Aug 28

Subsystems (2)
lore
Share & tools
lore

Andi Shyti

author
#0 lore raw

PATCH 1/1 media: cx231xx: Fix cleanup path on failure

If cx231xx_init_v4l2() fails the probe currently jumps to err_init, which only unregisters the V4L2 device. The analog devices and I2C resources are left registered while the driver state can be released.

A subsequent driver bind attempts to create the same I2C mux channel links and triggers a warning when the existing "channel-0" link is encountered. The remaining devices may also access released driver state. This produces the following warning

    can't create symlink to channel 0
    WARNING: drivers/i2c/i2c-mux.c:403 at i2c_mux_add_adapter+0xcd8/0xeb0
    Call Trace:
     i2c_mux_add_adapter+0xcdc/0xeb0
     cx231xx_dev_init+0x2fb/0x1260
     cx231xx_usb_probe+0xc48/0x2140
     usb_probe_interface+0x657/0xc70
     ...

Jump to err_video_alt instead, which performs the full device cleanup before unregistering the V4L2 device.

Fixes 4d2a7d3509f5 ("[media] cx231xx: move analog init code to a separate function")
Cc <[email protected]> # v3.17+

---
Hi Farhad,

thanks for your report. The failure happens in i2c-mux, but it is indeed a cx231xx in V4L2 issue. With your report it wasn't difficult to identify the problem, but to be sure I would appreciate it if you coud test this patch.

Can you also share your reproducer.c?

Thanks,
Andi

 drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-cards.c +1 -1
index 69b24205bc56..b0941cd2a2d8 100644
@@ -1826,7 +1826,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
 
 	retval = cx231xx_init_v4l2(dev, udev, interface, isoc_pipe);
 	if (retval)
-		goto err_init;
+		goto err_video_alt;
 
 	if (dev->current_pcb_config.ts1_source != 0xff) {
 		/* compute alternate max packet sizes for TS1 */
Signature · 1 line
2.55.0