* [PATCH] ACPI: scan: Fix a memory leak in an error handling path
@ 2021-05-08 7:23 Christophe JAILLET
2021-05-10 12:18 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-05-08 7:23 UTC (permalink / raw)
To: rjw, lenb, andriy.shevchenko
Cc: linux-acpi, linux-kernel, kernel-janitors, Christophe JAILLET
If 'acpi_device_set_name()' fails, we must free
'acpi_device_bus_id->bus_id' or there is a (potential) memory leak.
Fixes: eb50aaf960e3 ("ACPI: scan: Use unique number for instance_no")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/acpi/scan.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index a22778e880c2..651a431e2bbf 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -700,6 +700,7 @@ int acpi_device_add(struct acpi_device *device,
result = acpi_device_set_name(device, acpi_device_bus_id);
if (result) {
+ kfree_const(acpi_device_bus_id->bus_id);
kfree(acpi_device_bus_id);
goto err_unlock;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: scan: Fix a memory leak in an error handling path
2021-05-08 7:23 [PATCH] ACPI: scan: Fix a memory leak in an error handling path Christophe JAILLET
@ 2021-05-10 12:18 ` Andy Shevchenko
2021-05-10 17:04 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2021-05-10 12:18 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: rjw, lenb, linux-acpi, linux-kernel, kernel-janitors
On Sat, May 08, 2021 at 09:23:09AM +0200, Christophe JAILLET wrote:
> If 'acpi_device_set_name()' fails, we must free
> 'acpi_device_bus_id->bus_id' or there is a (potential) memory leak.
Good catch!
I guess I have lost it somewhere in the middle of developing the mentioned fix.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks!
> Fixes: eb50aaf960e3 ("ACPI: scan: Use unique number for instance_no")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/acpi/scan.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index a22778e880c2..651a431e2bbf 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -700,6 +700,7 @@ int acpi_device_add(struct acpi_device *device,
>
> result = acpi_device_set_name(device, acpi_device_bus_id);
> if (result) {
> + kfree_const(acpi_device_bus_id->bus_id);
> kfree(acpi_device_bus_id);
> goto err_unlock;
> }
> --
> 2.30.2
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: scan: Fix a memory leak in an error handling path
2021-05-10 12:18 ` Andy Shevchenko
@ 2021-05-10 17:04 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-05-10 17:04 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Christophe JAILLET, Rafael J. Wysocki, Len Brown,
ACPI Devel Maling List, Linux Kernel Mailing List,
kernel-janitors
On Mon, May 10, 2021 at 3:17 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Sat, May 08, 2021 at 09:23:09AM +0200, Christophe JAILLET wrote:
> > If 'acpi_device_set_name()' fails, we must free
> > 'acpi_device_bus_id->bus_id' or there is a (potential) memory leak.
>
> Good catch!
> I guess I have lost it somewhere in the middle of developing the mentioned fix.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Thanks!
>
> > Fixes: eb50aaf960e3 ("ACPI: scan: Use unique number for instance_no")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> > drivers/acpi/scan.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> > index a22778e880c2..651a431e2bbf 100644
> > --- a/drivers/acpi/scan.c
> > +++ b/drivers/acpi/scan.c
> > @@ -700,6 +700,7 @@ int acpi_device_add(struct acpi_device *device,
> >
> > result = acpi_device_set_name(device, acpi_device_bus_id);
> > if (result) {
> > + kfree_const(acpi_device_bus_id->bus_id);
> > kfree(acpi_device_bus_id);
> > goto err_unlock;
> > }
> > --
Applied as 5.13-rc material, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-10 17:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 7:23 [PATCH] ACPI: scan: Fix a memory leak in an error handling path Christophe JAILLET
2021-05-10 12:18 ` Andy Shevchenko
2021-05-10 17:04 ` Rafael J. Wysocki
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).