mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 08:35:19 -05:00
PNP: fix name memory leak in pnp_alloc_dev()
After commit1fa5ae857b
("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, move dev_set_name() after pnp_add_id() to avoid memory leak. Fixes:1fa5ae857b
("driver core: get rid of struct device's bus_id string array") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
eb7081409f
commit
110d7b0325
1 changed files with 2 additions and 2 deletions
|
@ -148,14 +148,14 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
|
||||||
dev->dev.coherent_dma_mask = dev->dma_mask;
|
dev->dev.coherent_dma_mask = dev->dma_mask;
|
||||||
dev->dev.release = &pnp_release_device;
|
dev->dev.release = &pnp_release_device;
|
||||||
|
|
||||||
dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number);
|
|
||||||
|
|
||||||
dev_id = pnp_add_id(dev, pnpid);
|
dev_id = pnp_add_id(dev, pnpid);
|
||||||
if (!dev_id) {
|
if (!dev_id) {
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue