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@xxxxxxxxxx> 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. Johan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html