Skip to content

Commit

Permalink
PNP: fix name memory leak in pnp_alloc_dev()
Browse files Browse the repository at this point in the history
After commit 1fa5ae8 ("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: 1fa5ae8 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: Yang Yingliang <[email protected]>
Reviewed-by: Hanjun Guo <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
Yang Yingliang authored and rafaeljw committed Nov 22, 2022
1 parent eb70814 commit 110d7b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/pnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.release = &pnp_release_device;

dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number);

dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
kfree(dev);
return NULL;
}

dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number);

return dev;
}

Expand Down

0 comments on commit 110d7b0

Please sign in to comment.