summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/fw-core.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-05-14 23:42:23 +0530
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-15 00:23:52 +0200
commit96ba6740099b1f1a2732c86204d2931cda11d638 (patch)
treeae84fd820a80b88593c07c072fc457ce9b627fdf /drivers/staging/greybus/fw-core.c
parent04f0e6ebd1a2ca3a1f1a356e9a07ef1797ef1b7c (diff)
greybus: fw-management: Free fw-mgmt only after all users are gone
The fw-management driver rightly destroys the char device on connection-exit, but that doesn't guarantee that all of the users of the device are gone. Userspace may still be holding file-descriptor of the char device and can initiate new ioctl operations. And that *will* lead to kernel crash. To avoid this issue, manage struct users with kref, manage a list of 'struct fw-mgmt' and start using the structure only after getting its kref incremented. The important part is the routine get_fw_mgmt(), which increments the reference to the struct before returning it to the caller. The list of fw-mgmt structs in protected with a mutex to avoid any races around that. The kref is incremented once the char device is opened and dropped only when it is closed. Reported-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/fw-core.c')
0 files changed, 0 insertions, 0 deletions