From: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Len Brown <lenb@kernel.org>,
srivatsa.bhat@linux.vnet.ibm.com, venki@google.com,
trenn@suse.de, bhelgaas@google.com,
kernel-janitors@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/acpi/processor_driver.c: add missing kfree
Date: Thu, 15 Mar 2012 09:44:49 +0000 [thread overview]
Message-ID: <4F61B741.1040102@linux.vnet.ibm.com> (raw)
In-Reply-To: <1331800325-14251-1-git-send-email-Julia.Lawall@lip6.fr>
On 03/15/2012 02:02 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> The function acpi_processor_add is stored in the ops.add field of a
> acpi_driver structure. This function is then called in
> acpi_bus_driver_init. On failure, this function clears the field
> device->driver_data, but does not free its contents. Thus the free has to
> be done by the add function. In acpi_processor_add, the corresponding
> value is pr. This value is currently freed on failure before storing it in
> device->driver_data, but not after. This free is added in the error
> handling code at the end of the function. The per_cpu variable
> processors is also cleared so that it does not refer to a dangling pointer.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
Acked-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
> ---
> drivers/acpi/processor_driver.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
> index 2801b41..98c3648 100644
> --- a/drivers/acpi/processor_driver.c
> +++ b/drivers/acpi/processor_driver.c
> @@ -536,8 +536,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
> return -ENOMEM;
>
> if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
> - kfree(pr);
> - return -ENOMEM;
> + result = -ENOMEM;
> + goto err_free_pr;
> }
>
> pr->handle = device->handle;
> @@ -577,7 +577,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
> dev = get_cpu_device(pr->id);
> if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
> result = -EFAULT;
> - goto err_free_cpumask;
> + goto err_clear_processor;
> }
>
> /*
> @@ -595,9 +595,14 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
>
> err_remove_sysfs:
> sysfs_remove_link(&device->dev.kobj, "sysdev");
> +err_clear_processor:
> + /* processor_device_array is not cleared to allow checks for buggy
> + BIOSes */
> + per_cpu(processors, pr->id) = NULL;
> err_free_cpumask:
> free_cpumask_var(pr->throttling.shared_cpu_map);
> -
> +err_free_pr:
> + kfree(pr);
> return result;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
WARNING: multiple messages have this Message-ID (diff)
From: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Len Brown <lenb@kernel.org>,
srivatsa.bhat@linux.vnet.ibm.com, venki@google.com,
trenn@suse.de, bhelgaas@google.com,
kernel-janitors@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/acpi/processor_driver.c: add missing kfree
Date: Thu, 15 Mar 2012 15:02:49 +0530 [thread overview]
Message-ID: <4F61B741.1040102@linux.vnet.ibm.com> (raw)
In-Reply-To: <1331800325-14251-1-git-send-email-Julia.Lawall@lip6.fr>
On 03/15/2012 02:02 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> The function acpi_processor_add is stored in the ops.add field of a
> acpi_driver structure. This function is then called in
> acpi_bus_driver_init. On failure, this function clears the field
> device->driver_data, but does not free its contents. Thus the free has to
> be done by the add function. In acpi_processor_add, the corresponding
> value is pr. This value is currently freed on failure before storing it in
> device->driver_data, but not after. This free is added in the error
> handling code at the end of the function. The per_cpu variable
> processors is also cleared so that it does not refer to a dangling pointer.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
Acked-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
> ---
> drivers/acpi/processor_driver.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
> index 2801b41..98c3648 100644
> --- a/drivers/acpi/processor_driver.c
> +++ b/drivers/acpi/processor_driver.c
> @@ -536,8 +536,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
> return -ENOMEM;
>
> if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
> - kfree(pr);
> - return -ENOMEM;
> + result = -ENOMEM;
> + goto err_free_pr;
> }
>
> pr->handle = device->handle;
> @@ -577,7 +577,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
> dev = get_cpu_device(pr->id);
> if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
> result = -EFAULT;
> - goto err_free_cpumask;
> + goto err_clear_processor;
> }
>
> /*
> @@ -595,9 +595,14 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
>
> err_remove_sysfs:
> sysfs_remove_link(&device->dev.kobj, "sysdev");
> +err_clear_processor:
> + /* processor_device_array is not cleared to allow checks for buggy
> + BIOSes */
> + per_cpu(processors, pr->id) = NULL;
> err_free_cpumask:
> free_cpumask_var(pr->throttling.shared_cpu_map);
> -
> +err_free_pr:
> + kfree(pr);
> return result;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2012-03-15 9:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-10 17:05 [PATCH] drivers/acpi/processor_driver.c: add missing kfree Julia Lawall
2012-03-10 17:05 ` Julia Lawall
2012-03-14 11:34 ` Srivatsa S. Bhat
2012-03-14 11:46 ` Srivatsa S. Bhat
2012-03-14 12:32 ` Julia Lawall
2012-03-14 12:32 ` Julia Lawall
2012-03-14 12:50 ` Srivatsa S. Bhat
2012-03-14 13:02 ` Srivatsa S. Bhat
2012-03-15 8:32 ` Julia Lawall
2012-03-15 8:32 ` Julia Lawall
2012-03-15 9:07 ` Srivatsa S. Bhat
2012-03-15 9:19 ` Srivatsa S. Bhat
2012-03-15 9:32 ` Deepthi Dharwar [this message]
2012-03-15 9:44 ` Deepthi Dharwar
2012-03-16 10:02 ` Julia Lawall
2012-03-16 10:02 ` Julia Lawall
2012-03-17 15:38 ` Julia Lawall
2012-03-17 15:38 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F61B741.1040102@linux.vnet.ibm.com \
--to=deepthi@linux.vnet.ibm.com \
--cc=Julia.Lawall@lip6.fr \
--cc=bhelgaas@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=trenn@suse.de \
--cc=venki@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.