* sony-laptop: fix early NULL pointer dereference
[not found] ` <BANLkTimJa3CSWouTMJD5V0ZuMa67YXy88Q@mail.gmail.com>
@ 2011-04-04 23:44 ` Mattia Dongili
2011-04-05 0:26 ` Thiago Farina
0 siblings, 1 reply; 3+ messages in thread
From: Mattia Dongili @ 2011-04-04 23:44 UTC (permalink / raw)
Cc: Andrea Gelmini, Matthew Garrett, anssi.hannula, linux-acpi,
axel.lin, trenn, len.brown, linux-kernel, Dan Carpenter,
platform-driver-x86
Author: Mattia Dongili <malattia@linux.it>
Date: Fri Apr 1 10:01:41 2011 +0900
sony-laptop: fix early NULL pointer dereference
The SNC acpi driver could get early notifications before it fully
initializes and that could lead to dereferencing the sony_nc_handles
structure pointer that is still NULL at that stage.
Make sure we return early from the handle lookup function in these
cases.
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
Hi Matthew,
if it's not too late, can you pick this one up instead of the previous
one (89ec2feafaedd759e53346d641f60863a14cfb9e)?
If it's too late I'll try and do a round of return value fixes later.
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index b2ce172..de79c18 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct platform_device *pd)
static int sony_find_snc_handle(int handle)
{
int i;
+
+ /* not initialized yet, return early */
+ if (!handles)
+ return -EINVAL;
+
for (i = 0; i < 0x10; i++) {
if (handles->cap[i] == handle) {
dprintk("found handle 0x%.4x (offset: 0x%.2x)\n",
--
mattia
:wq!
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: sony-laptop: fix early NULL pointer dereference
2011-04-04 23:44 ` sony-laptop: fix early NULL pointer dereference Mattia Dongili
@ 2011-04-05 0:26 ` Thiago Farina
2011-04-05 12:50 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Thiago Farina @ 2011-04-05 0:26 UTC (permalink / raw)
To: Mattia Dongili
Cc: Matthew Garrett, Andrea Gelmini, anssi.hannula, linux-acpi,
axel.lin, trenn, len.brown, linux-kernel, Dan Carpenter,
platform-driver-x86
On Mon, Apr 4, 2011 at 8:44 PM, Mattia Dongili <malattia@linux.it> wrote:
> Author: Mattia Dongili <malattia@linux.it>
> Date: Fri Apr 1 10:01:41 2011 +0900
>
I think most of the patches doesn't include these above lines nor the
subject line in the description. Also when submitting a patch to the
list, please don't forget to put [PATCH] on the subject line.
git format-patch should output the right format.
> sony-laptop: fix early NULL pointer dereference
>
> The SNC acpi driver could get early notifications before it fully
> initializes and that could lead to dereferencing the sony_nc_handles
> structure pointer that is still NULL at that stage.
> Make sure we return early from the handle lookup function in these
> cases.
>
> Signed-off-by: Mattia Dongili <malattia@linux.it>
> ---
>
> Hi Matthew,
> if it's not too late, can you pick this one up instead of the previous
> one (89ec2feafaedd759e53346d641f60863a14cfb9e)?
> If it's too late I'll try and do a round of return value fixes later.
>
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index b2ce172..de79c18 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct platform_device *pd)
> static int sony_find_snc_handle(int handle)
> {
> int i;
> +
> + /* not initialized yet, return early */
This comment is useless, it is just repeating what the codes does ;) I
think you can just remove it.
> + if (!handles)
> + return -EINVAL;
> +
> for (i = 0; i < 0x10; i++) {
> if (handles->cap[i] == handle) {
> dprintk("found handle 0x%.4x (offset: 0x%.2x)\n",
> --
> mattia
> :wq!
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sony-laptop: fix early NULL pointer dereference
2011-04-05 0:26 ` Thiago Farina
@ 2011-04-05 12:50 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2011-04-05 12:50 UTC (permalink / raw)
To: Thiago Farina
Cc: Mattia Dongili, Matthew Garrett, Andrea Gelmini, anssi.hannula,
linux-acpi, axel.lin, trenn, len.brown, linux-kernel,
platform-driver-x86
On 4/5/11, Thiago Farina <tfransosi@gmail.com> wrote:
> On Mon, Apr 4, 2011 at 8:44 PM, Mattia Dongili <malattia@linux.it> wrote:
>> Author: Mattia Dongili <malattia@linux.it>
>> Date: Fri Apr 1 10:01:41 2011 +0900
>>
> I think most of the patches doesn't include these above lines nor the
> subject line in the description.
Just ignore those lines. It's a git thing.
> Also when submitting a patch to the
> list, please don't forget to put [PATCH] on the subject line.
>
Yeah. [patch v2]. But it's too late to fix that so don't worry about it.
> git format-patch should output the right format.
>
>> sony-laptop: fix early NULL pointer dereference
>>
>> The SNC acpi driver could get early notifications before it fully
>> initializes and that could lead to dereferencing the sony_nc_handles
>> structure pointer that is still NULL at that stage.
>> Make sure we return early from the handle lookup function in these
>> cases.
>>
>> Signed-off-by: Mattia Dongili <malattia@linux.it>
>> ---
>>
>> Hi Matthew,
>> if it's not too late, can you pick this one up instead of the previous
>> one (89ec2feafaedd759e53346d641f60863a14cfb9e)?
>> If it's too late I'll try and do a round of return value fixes later.
Don't worry about it. Probably the real fix is to make checkpatch.pl
complain if you return -1 instead of a proper error code.
>>
>> diff --git a/drivers/platform/x86/sony-laptop.c
>> b/drivers/platform/x86/sony-laptop.c
>> index b2ce172..de79c18 100644
>> --- a/drivers/platform/x86/sony-laptop.c
>> +++ b/drivers/platform/x86/sony-laptop.c
>> @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct
>> platform_device *pd)
>> static int sony_find_snc_handle(int handle)
>> {
>> int i;
>> +
>> + /* not initialized yet, return early */
> This comment is useless, it is just repeating what the codes does ;) I
> think you can just remove it.
Whatever... Let's just merge this fix and let's move on.
regards,
dan carpenter
>
>> + if (!handles)
>> + return -EINVAL;
>> +
>> for (i = 0; i < 0x10; i++) {
>> if (handles->cap[i] == handle) {
>> dprintk("found handle 0x%.4x (offset: 0x%.2x)\n",
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-05 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <AANLkTi=1xtjEZc2C1=W-v2oYbvvcGH9k_DGGXvJ8=swq@mail.gmail.com>
[not found] ` <20110401172241.GA26851@srcf.ucam.org>
[not found] ` <BANLkTikPjwowBge82viT+Ma5UnP0fA-pew@mail.gmail.com>
[not found] ` <20110402100043.GA5890@kamineko.org>
[not found] ` <BANLkTikVGWM3T1y2XvwkHB+Yub5EhG1RPA@mail.gmail.com>
[not found] ` <20110402155549.GA6724@kamineko.org>
[not found] ` <BANLkTimJa3CSWouTMJD5V0ZuMa67YXy88Q@mail.gmail.com>
2011-04-04 23:44 ` sony-laptop: fix early NULL pointer dereference Mattia Dongili
2011-04-05 0:26 ` Thiago Farina
2011-04-05 12:50 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox