forked from Minki/linux
mISDN: fix possible memory leak in mISDN_register_device()
Afer commit1fa5ae857b
("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, add put_device() to give up the reference, so that the name can be freed in kobject_cleanup() when the refcount is 0. Set device class before put_device() to avoid null release() function WARN message in device_release(). Fixes:1fa5ae857b
("driver core: get rid of struct device's bus_id string array") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e97c089d7a
commit
e7d1d4d9ac
@ -233,11 +233,12 @@ mISDN_register_device(struct mISDNdevice *dev,
|
||||
if (debug & DEBUG_CORE)
|
||||
printk(KERN_DEBUG "mISDN_register %s %d\n",
|
||||
dev_name(&dev->dev), dev->id);
|
||||
dev->dev.class = &mISDN_class;
|
||||
|
||||
err = create_stack(dev);
|
||||
if (err)
|
||||
goto error1;
|
||||
|
||||
dev->dev.class = &mISDN_class;
|
||||
dev->dev.platform_data = dev;
|
||||
dev->dev.parent = parent;
|
||||
dev_set_drvdata(&dev->dev, dev);
|
||||
@ -249,8 +250,8 @@ mISDN_register_device(struct mISDNdevice *dev,
|
||||
|
||||
error3:
|
||||
delete_stack(dev);
|
||||
return err;
|
||||
error1:
|
||||
put_device(&dev->dev);
|
||||
return err;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user