USB: usbip: vudc: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 3 Nov 2023 17:14:29 +0000 (18:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Nov 2023 12:02:53 +0000 (12:02 +0000)
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20231103171428.3636570-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/vudc.h
drivers/usb/usbip/vudc_dev.c
drivers/usb/usbip/vudc_main.c

index 1bd4bc005829bdb71f85861d7ef57d27bf709660..faf61c9c6a9894269f3b171467e7bad238406248 100644 (file)
@@ -173,6 +173,6 @@ struct vudc_device *alloc_vudc_device(int devid);
 void put_vudc_device(struct vudc_device *udc_dev);
 
 int vudc_probe(struct platform_device *pdev);
-int vudc_remove(struct platform_device *pdev);
+void vudc_remove(struct platform_device *pdev);
 
 #endif /* __USBIP_VUDC_H */
index 44b04c54c08677155b747b28f272e91ec21d0f21..f11535020e35a3beb67f7403bccc4e0295525ed7 100644 (file)
@@ -628,12 +628,11 @@ out:
        return ret;
 }
 
-int vudc_remove(struct platform_device *pdev)
+void vudc_remove(struct platform_device *pdev)
 {
        struct vudc *udc = platform_get_drvdata(pdev);
 
        usb_del_gadget_udc(&udc->gadget);
        cleanup_vudc_hw(udc);
        kfree(udc);
-       return 0;
 }
index 993e721cb840df29c209bbad2bfc35fea434b4db..8bee553e48945f66d6c81bd0c1e0d2ca22f798ae 100644 (file)
@@ -19,7 +19,7 @@ MODULE_PARM_DESC(num, "number of emulated controllers");
 
 static struct platform_driver vudc_driver = {
        .probe          = vudc_probe,
-       .remove         = vudc_remove,
+       .remove_new     = vudc_remove,
        .driver         = {
                .name   = GADGET_NAME,
                .dev_groups = vudc_groups,