Skip to contentSkip to conversation

USB: serial: ftdi_sio: Add MTP NVM support

DISCUSSION Johan Hovold 1 participant 1 message Jun 19, 2018 USB

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines · Loic Poulain

Hi Johan, Srini,

Quoted 6 lines · Srinivas Kandagatla
Quoted 4 lines · Johan Hovold

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.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

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 2 lines

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 3 lines
Quoted 1 line

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.

Johan
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html