From: "Denis Efremov (Oracle)" <efremov@linux.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>, Greg Kroah-Hartman <gregkh@suse.de>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] floppy: fix reference leak on platform_device_register() failure
Date: Wed, 15 Apr 2026 18:15:56 +0400 [thread overview]
Message-ID: <376f0e18-fae3-45d7-b3bf-885e963e6b51@linux.com> (raw)
In-Reply-To: <CANUHTR9MQ8GGpgtGDgRCmjQL_D0jW4E-2OER4Q784xbGd+nJSw@mail.gmail.com>
On 15/04/2026 17:54, Guangshuo Li wrote:
> Hi Denis,
>
> Thank you for the review.
>
> On Wed, 15 Apr 2026 at 21:00, Denis Efremov (Oracle) <efremov@linux.com> wrote:
>>
>> 1. Let's use platform_device_put()
>>
>>> goto out_remove_drives;
>>> + }
>>>
>>> registered[drive] = true;
>>>
>
> My understanding is:
>
> For the platform_device_register() failure case, we should use
> platform_device_put() instead of put_device(), so the failure path
> would look like:
>
> err = platform_device_register(&floppy_device[drive]);
> if (err) {
> platform_device_put(&floppy_device[drive]);
> goto out_remove_drives;
> }
> registered[drive] = true;
Yes, correct.
>
>> err = device_add_disk(&floppy_device[drive].dev,
>> disks[drive][0], NULL);
>> if (err)
>> goto out_remove_drives;
>>
>> 2. We also need to fix this case.
>>
>> platform_device_unregister()
>> registered[drive] = false;
>> goto ...
>>
>> Thanks,
>> Denis
> We also need to handle the device_add_disk() failure case for the
> current drive, since out_remove_drives only cleans up previously
> registered drives. So this path should explicitly unregister the
> current platform device before jumping to the common cleanup path, for
> example:
>
> err = device_add_disk(&floppy_device[drive].dev, disks[drive][0], NULL);
> if (err) {
> platform_device_unregister(&floppy_device[drive]);
> registered[drive] = false;
> goto out_remove_drives;
> }
>
>
> Is my understanding correct? If so, I will prepare and send a v2
> following this pattern.
Yes, correct. Please, send v2.
>
> Thanks,
> Guangshuo
prev parent reply other threads:[~2026-04-15 14:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 15:31 [PATCH] floppy: fix reference leak on platform_device_register() failure Guangshuo Li
2026-04-15 13:00 ` Denis Efremov (Oracle)
2026-04-15 13:54 ` Guangshuo Li
2026-04-15 14:15 ` Denis Efremov (Oracle) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=376f0e18-fae3-45d7-b3bf-885e963e6b51@linux.com \
--to=efremov@linux.com \
--cc=axboe@kernel.dk \
--cc=gregkh@suse.de \
--cc=lgs201920130244@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox