USB: serial: ftdi_sio: Add MTP NVM support

From: Loic Poulain <hidden>
Date: 2018-06-20 08:52:18

Hi Johan, Srini,

On 19 June 2018 at 15:06, Johan Hovold [off-list ref] wrote:
On Tue, Jun 19, 2018 at 02:32:11PM +0200, Loic Poulain wrote:
quoted
Hi Johan, Srini,

On 18 June 2018 at 11:47, Srinivas Kandagatla
[off-list ref] wrote:
quoted
On 18/06/18 09:46, Johan Hovold wrote:
quoted
quoted
quoted
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.
quoted
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.
quoted
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help