On Wed, Jun 29, 2016 at 10:53 AM, Alexander Stein <alexander.stein@xxxxxxxxxxxxxxxxxxxxx> wrote: > On Thursday 02 June 2016 13:51:26, Linus Walleij wrote: >> + fd = anon_inode_getfd("gpio-linehandle", >> + &linehandle_fileops, >> + lh, >> + O_RDONLY | O_CLOEXEC); > > When will linehandle_release actually be called? When we explicitely call > close(req.fd) or when application exits and all FDs will be closed anyway? As far as I understand: both. And I don't think anything else makes sense? If an application is terminated, the operating environment will close all open file handles as far as I know, at least that is how I always thought it works. But hey, it's userspace so what do I know... Anyways if it doesn't work like so, there are a bunch of subsystems in the kernel using it so they would all have severe problems. >> + if (fd < 0) { >> + ret = fd; >> + goto out_free_descs; >> + } >> + >> + handlereq.fd = fd; >> + if (copy_to_user(ip, &handlereq, sizeof(handlereq))) >> + return -EFAULT; > > If I'm right above doesn't that then leak lh until application eventually > exits? Userspace won't receive the newly created fd. The same would apply to > patch 3/4. I don't understand.... The userspace application reads the .fd fields of the handle request after issuing the ioctl() and it then contains the new file handle. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html