Skip to content

Commit

Permalink
pktcdvd: fix BUG caused by sysfs module reference semantics change
Browse files Browse the repository at this point in the history
pkt_setup_dev() expects module reference to be held on invocation.
This used to be true for sysfs callbacks but not anymore.  Test and
grab module reference around pkt_setup_dev() in
class_pktcdvd_store_add().

Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Peter Osterlund <petero2@telia.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
htejun authored and Jens Axboe committed Nov 8, 2007
1 parent 8ec680e commit fffe487
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,19 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
size_t count)
{
unsigned int major, minor;

if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
/* pkt_setup_dev() expects caller to hold reference to self */
if (!try_module_get(THIS_MODULE))
return -ENODEV;

pkt_setup_dev(MKDEV(major, minor), NULL);

module_put(THIS_MODULE);

return count;
}

return -EINVAL;
}

Expand Down

0 comments on commit fffe487

Please sign in to comment.