From: Loic Poulain <loic.poulain@linaro.org>
To: Johan Hovold <johan@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
linux-usb@vger.kernel.org,
Daniel Thompson <daniel.thompson@linaro.org>
Subject: USB: serial: ftdi_sio: Add MTP NVM support
Date: Wed, 20 Jun 2018 10:52:18 +0200 [thread overview]
Message-ID: <CAMZdPi-P5Vak8vK25UFxuZ2-GqZUM7hSbcEZE34L-t-+5cvEvA@mail.gmail.com> (raw)
Hi Johan, Srini,
On 19 June 2018 at 15:06, Johan Hovold <johan@kernel.org> wrote:
> On Tue, Jun 19, 2018 at 02:32:11PM +0200, Loic Poulain wrote:
>> Hi Johan, Srini,
>>
>> On 18 June 2018 at 11:47, Srinivas Kandagatla
>> <srinivas.kandagatla@linaro.org> wrote:
>> > On 18/06/18 09:46, Johan Hovold wrote:
>
>> >> I'm not necessarily against the idea, but nvmem core needs to be fixed
>> >> so that it can handle hotplugging before this can be considered for
>> >> merging.
>> >>
>> >> Right now it just returns -EBUSY from nvmem_unregister(), which results
>> >> in all kinds of memory leaks, use-after-frees and crashes when user
>> >> space holds the character device open while the device is being
>> >> unplugged.
>>
>> Correct me if I'm wrong, but nvmem is just exposed to userspace as a
>> simple sysfs device attribute (nvmem), removing a device and its attribute(s)
>> dynamically is well managed by sysfs, even if userspace has file open.
>
> My bad, I misremembered what interface nvmem was using and only saw the
> deregistration refusal in nvmem_unregister() during a quick check.
>
>> The only risk here is when a kernel internal consumer still has a reference to
>> the nvmem device on removal, which is not the case in our context.
>
> Right.
>
>> > I can also suggest you to try devm_nvmem_register().
>>
>> Yes, I'm going to send a v2.
>
> I'll take a closer look soonish too.
I changed my mind here, indeed, in order to avoid any potential
use-after-free, we have to manually unregister/release the nvmem
device before freeing of the private port structure (used as nvmem
context). So I will not send a V2 with nvmem devm usage. You can
consider this V1 for review.
Regards,
Loic
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2018-06-20 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 8:52 Loic Poulain [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-06-20 9:09 USB: serial: ftdi_sio: Add MTP NVM support Srinivas Kandagatla
2018-06-19 13:06 Johan Hovold
2018-06-19 12:32 Loic Poulain
2018-06-18 9:47 Srinivas Kandagatla
2018-06-18 8:46 Johan Hovold
2018-06-14 20:08 Loic Poulain
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=CAMZdPi-P5Vak8vK25UFxuZ2-GqZUM7hSbcEZE34L-t-+5cvEvA@mail.gmail.com \
--to=loic.poulain@linaro.org \
--cc=daniel.thompson@linaro.org \
--cc=johan@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.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;
as well as URLs for NNTP newsgroup(s).