* [PATCH -next 1/2] PCI: fix possible memory leak in error case in pci_setup_device()
@ 2022-08-17 8:44 Yang Yingliang
2022-08-17 8:44 ` [PATCH -next 2/2] PCI: switch to use dev_err_probe() Yang Yingliang
0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-08-17 8:44 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas
If pci_setup_device() fails, the device name need be freed
to avoid memory leak.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/pci/probe.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c5286b027f00..0e947f24153e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1976,6 +1976,7 @@ int pci_setup_device(struct pci_dev *dev)
default: /* unknown header */
pci_err(dev, "unknown header type %02x, ignoring device\n",
dev->hdr_type);
+ kfree_const(dev->dev.kobj.name);
pci_release_of_node(dev);
return -EIO;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH -next 2/2] PCI: switch to use dev_err_probe()
2022-08-17 8:44 [PATCH -next 1/2] PCI: fix possible memory leak in error case in pci_setup_device() Yang Yingliang
@ 2022-08-17 8:44 ` Yang Yingliang
2022-08-17 9:11 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-08-17 8:44 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas
Use dev_err_probe() to simplify code and print error code.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/pci/probe.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0e947f24153e..f2430da8a30b 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3054,10 +3054,9 @@ int pci_host_probe(struct pci_host_bridge *bridge)
int ret;
ret = pci_scan_root_bus_bridge(bridge);
- if (ret < 0) {
- dev_err(bridge->dev.parent, "Scanning root bridge failed");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(bridge->dev.parent, ret,
+ "Scanning root bridge failed");
bus = bridge->bus;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next 2/2] PCI: switch to use dev_err_probe()
2022-08-17 8:44 ` [PATCH -next 2/2] PCI: switch to use dev_err_probe() Yang Yingliang
@ 2022-08-17 9:11 ` Christophe JAILLET
0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-08-17 9:11 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, linux-pci; +Cc: bhelgaas
Le 17/08/2022 à 10:44, Yang Yingliang a écrit :
> Use dev_err_probe() to simplify code and print error code.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/pci/probe.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 0e947f24153e..f2430da8a30b 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -3054,10 +3054,9 @@ int pci_host_probe(struct pci_host_bridge *bridge)
> int ret;
>
> ret = pci_scan_root_bus_bridge(bridge);
> - if (ret < 0) {
> - dev_err(bridge->dev.parent, "Scanning root bridge failed");
> - return ret;
> - }
> + if (ret < 0)
> + return dev_err_probe(bridge->dev.parent, ret,
> + "Scanning root bridge failed");
>
> bus = bridge->bus;
>
Nit: you could also add a \n at the end of the message.
Just my 2c,
CJ
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-17 9:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17 8:44 [PATCH -next 1/2] PCI: fix possible memory leak in error case in pci_setup_device() Yang Yingliang
2022-08-17 8:44 ` [PATCH -next 2/2] PCI: switch to use dev_err_probe() Yang Yingliang
2022-08-17 9:11 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).