Re: [PATCH v2] media: rtl28xxu: fix SDR platform device leak

From: Markus Elfring

Date: Thu Sep 24 2026 - 13:07:18 EST


…
> +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
> @@ -1391,8 +1391,16 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
> "rtl2832_sdr",
> PLATFORM_DEVID_AUTO,
> &pdata, sizeof(pdata));
> - if (IS_ERR(pdev) || pdev->dev.driver == NULL)
> + if (IS_ERR(pdev))
> break;
> + if (!pdev->dev.driver) {
> + platform_device_unregister(pdev);
> + break;
> + }
> + if (!try_module_get(pdev->dev.driver->owner)) {
> + platform_device_unregister(pdev);
> + break;
> + }
…

How do you think about to avoid a bit of duplicate source code
by merging two condition checks into a disjunction?

Regards,
Markus