* [PATCH 6/12] drivers/platform/x86: Correct redundant test
@ 2009-07-27 16:14 ` Julia Lawall
0 siblings, 0 replies; 16+ messages in thread
From: Julia Lawall @ 2009-07-27 16:14 UTC (permalink / raw)
To: jwoithe, linux-acpi, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
device and acpi_driver_data(device) were tested just a few lines above.
A simplified version of the semantic match that finds this problem is as
follows: (http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
expression E;
@@
if (x = NULL || ...) { ... when forall
return ...; }
... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
(
*x = NULL
|
*x != NULL
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/platform/x86/fujitsu-laptop.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 218b9a1..5306901 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type)
fujitsu = acpi_driver_data(device);
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
fujitsu->acpi_handle = NULL;
return 0;
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-27 16:14 ` Julia Lawall 0 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-27 16:14 UTC (permalink / raw) To: jwoithe, linux-acpi, linux-kernel, kernel-janitors From: Julia Lawall <julia@diku.dk> device and acpi_driver_data(device) were tested just a few lines above. A simplified version of the semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; expression E; @@ if (x == NULL || ...) { ... when forall return ...; } ... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\) ( *x == NULL | *x != NULL ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> --- drivers/platform/x86/fujitsu-laptop.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 218b9a1..5306901 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) - return -EINVAL; - fujitsu->acpi_handle = NULL; return 0; ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-27 16:14 ` Julia Lawall @ 2009-07-28 17:52 ` Paulo Marques -1 siblings, 0 replies; 16+ messages in thread From: Paulo Marques @ 2009-07-28 17:52 UTC (permalink / raw) To: Julia Lawall; +Cc: jwoithe, linux-acpi, linux-kernel, kernel-janitors Julia Lawall wrote: > [...] > --- > drivers/platform/x86/fujitsu-laptop.c | 3 --- > 1 files changed, 0 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > index 218b9a1..5306901 100644 > --- a/drivers/platform/x86/fujitsu-laptop.c > +++ b/drivers/platform/x86/fujitsu-laptop.c > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > - return -EINVAL; > - Shouldn't this still do a: if (!fujitsu) return -EINVAL; to avoid dereferencing a NULL pointer below? > fujitsu->acpi_handle = NULL; > > return 0; -- Paulo Marques - www.grupopie.com "All I ask is a chance to prove that money can't make me happy." ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-28 17:52 ` Paulo Marques 0 siblings, 0 replies; 16+ messages in thread From: Paulo Marques @ 2009-07-28 17:52 UTC (permalink / raw) To: Julia Lawall; +Cc: jwoithe, linux-acpi, linux-kernel, kernel-janitors Julia Lawall wrote: > [...] > --- > drivers/platform/x86/fujitsu-laptop.c | 3 --- > 1 files changed, 0 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > index 218b9a1..5306901 100644 > --- a/drivers/platform/x86/fujitsu-laptop.c > +++ b/drivers/platform/x86/fujitsu-laptop.c > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > - return -EINVAL; > - Shouldn't this still do a: if (!fujitsu) return -EINVAL; to avoid dereferencing a NULL pointer below? > fujitsu->acpi_handle = NULL; > > return 0; -- Paulo Marques - www.grupopie.com "All I ask is a chance to prove that money can't make me happy." ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-28 17:52 ` Paulo Marques @ 2009-07-28 20:11 ` Julia Lawall -1 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-28 20:11 UTC (permalink / raw) To: Paulo Marques; +Cc: jwoithe, linux-acpi, linux-kernel, kernel-janitors On Tue, 28 Jul 2009, Paulo Marques wrote: > Julia Lawall wrote: > > [...] > > --- > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > index 218b9a1..5306901 100644 > > --- a/drivers/platform/x86/fujitsu-laptop.c > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > fujitsu = acpi_driver_data(device); > > > > - if (!device || !acpi_driver_data(device)) > > - return -EINVAL; > > - > > Shouldn't this still do a: > > if (!fujitsu) > return -EINVAL; acpi_driver_data just accesses a field of its argument. Is there a worry that from one call to the next it could have a different value? Perhaps it would be better to first test !device, then initialize fujitsu, and then test the result of fujitsu? The acpi_driver_data, which might someday do something more complicated, would only be called once. julia ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-28 20:11 ` Julia Lawall 0 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-28 20:11 UTC (permalink / raw) To: Paulo Marques; +Cc: jwoithe, linux-acpi, linux-kernel, kernel-janitors On Tue, 28 Jul 2009, Paulo Marques wrote: > Julia Lawall wrote: > > [...] > > --- > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > index 218b9a1..5306901 100644 > > --- a/drivers/platform/x86/fujitsu-laptop.c > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > fujitsu = acpi_driver_data(device); > > > > - if (!device || !acpi_driver_data(device)) > > - return -EINVAL; > > - > > Shouldn't this still do a: > > if (!fujitsu) > return -EINVAL; acpi_driver_data just accesses a field of its argument. Is there a worry that from one call to the next it could have a different value? Perhaps it would be better to first test !device, then initialize fujitsu, and then test the result of fujitsu? The acpi_driver_data, which might someday do something more complicated, would only be called once. julia ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-28 17:52 ` Paulo Marques (?) @ 2009-07-29 0:50 ` Jonathan Woithe -1 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 0:50 UTC (permalink / raw) To: Paulo Marques Cc: Julia Lawall, jwoithe, linux-acpi, linux-kernel, kernel-janitors Hi guys > Julia Lawall wrote: > > [...] > > --- > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > index 218b9a1..5306901 100644 > > --- a/drivers/platform/x86/fujitsu-laptop.c > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > fujitsu = acpi_driver_data(device); > > > > - if (!device || !acpi_driver_data(device)) > > - return -EINVAL; > > - > > Shouldn't this still do a: > > if (!fujitsu) > return -EINVAL; > > to avoid dereferencing a NULL pointer below? Hmm, yes it should. Well spotted. And I'm not certain how the duplicate test on "device" got in there in the first place. I suspect it came about due to some structural changes made a few versions ago and I failed to notice that the second check became redundant. So, combining this with the above patch we should instead do Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 10:14:30.610249941 +0930 @@ -745,7 +745,7 @@ static int acpi_fujitsu_remove(struct ac fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 0:50 ` Jonathan Woithe 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 1:02 UTC (permalink / raw) To: Paulo Marques Cc: Julia Lawall, jwoithe, linux-acpi, linux-kernel, kernel-janitors Hi guys > Julia Lawall wrote: > > [...] > > --- > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > index 218b9a1..5306901 100644 > > --- a/drivers/platform/x86/fujitsu-laptop.c > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > fujitsu = acpi_driver_data(device); > > > > - if (!device || !acpi_driver_data(device)) > > - return -EINVAL; > > - > > Shouldn't this still do a: > > if (!fujitsu) > return -EINVAL; > > to avoid dereferencing a NULL pointer below? Hmm, yes it should. Well spotted. And I'm not certain how the duplicate test on "device" got in there in the first place. I suspect it came about due to some structural changes made a few versions ago and I failed to notice that the second check became redundant. So, combining this with the above patch we should instead do Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 10:14:30.610249941 +0930 @@ -745,7 +745,7 @@ static int acpi_fujitsu_remove(struct ac fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 0:50 ` Jonathan Woithe 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 0:50 UTC (permalink / raw) To: Paulo Marques Cc: Julia Lawall, jwoithe, linux-acpi, linux-kernel, kernel-janitors Hi guys > Julia Lawall wrote: > > [...] > > --- > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > index 218b9a1..5306901 100644 > > --- a/drivers/platform/x86/fujitsu-laptop.c > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > fujitsu = acpi_driver_data(device); > > > > - if (!device || !acpi_driver_data(device)) > > - return -EINVAL; > > - > > Shouldn't this still do a: > > if (!fujitsu) > return -EINVAL; > > to avoid dereferencing a NULL pointer below? Hmm, yes it should. Well spotted. And I'm not certain how the duplicate test on "device" got in there in the first place. I suspect it came about due to some structural changes made a few versions ago and I failed to notice that the second check became redundant. So, combining this with the above patch we should instead do Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 10:14:30.610249941 +0930 @@ -745,7 +745,7 @@ static int acpi_fujitsu_remove(struct ac fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-29 0:50 ` Jonathan Woithe @ 2009-07-29 2:22 ` Julia Lawall -1 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-29 2:22 UTC (permalink / raw) To: Jonathan Woithe; +Cc: Paulo Marques, linux-acpi, linux-kernel, kernel-janitors On Wed, 29 Jul 2009, Jonathan Woithe wrote: > Hi guys > > > Julia Lawall wrote: > > > [...] > > > --- > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > index 218b9a1..5306901 100644 > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > fujitsu = acpi_driver_data(device); > > > > > > - if (!device || !acpi_driver_data(device)) > > > - return -EINVAL; > > > - > > > > Shouldn't this still do a: > > > > if (!fujitsu) > > return -EINVAL; > > > > to avoid dereferencing a NULL pointer below? > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > test on "device" got in there in the first place. I suspect it came about > due to some structural changes made a few versions ago and I failed to > notice that the second check became redundant. If you are going to check fujitsu afterwards, then I think there is no need to test the result of acpi_driver_data before. julia > So, combining this with the above patch we should instead do > > Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> > > --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 > +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 10:14:30.610249941 +0930 > @@ -745,7 +745,7 @@ static int acpi_fujitsu_remove(struct ac > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > + if (!fujitsu) > return -EINVAL; > > fujitsu->acpi_handle = NULL; > > Regards > jonathan > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" 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] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 2:22 ` Julia Lawall 0 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-29 2:22 UTC (permalink / raw) To: Jonathan Woithe; +Cc: Paulo Marques, linux-acpi, linux-kernel, kernel-janitors On Wed, 29 Jul 2009, Jonathan Woithe wrote: > Hi guys > > > Julia Lawall wrote: > > > [...] > > > --- > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > index 218b9a1..5306901 100644 > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > fujitsu = acpi_driver_data(device); > > > > > > - if (!device || !acpi_driver_data(device)) > > > - return -EINVAL; > > > - > > > > Shouldn't this still do a: > > > > if (!fujitsu) > > return -EINVAL; > > > > to avoid dereferencing a NULL pointer below? > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > test on "device" got in there in the first place. I suspect it came about > due to some structural changes made a few versions ago and I failed to > notice that the second check became redundant. If you are going to check fujitsu afterwards, then I think there is no need to test the result of acpi_driver_data before. julia > So, combining this with the above patch we should instead do > > Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> > > --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 > +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 10:14:30.610249941 +0930 > @@ -745,7 +745,7 @@ static int acpi_fujitsu_remove(struct ac > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > + if (!fujitsu) > return -EINVAL; > > fujitsu->acpi_handle = NULL; > > Regards > jonathan > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" 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] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-29 2:22 ` Julia Lawall (?) @ 2009-07-29 2:42 ` Jonathan Woithe -1 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 2:42 UTC (permalink / raw) To: Julia Lawall Cc: Jonathan Woithe, Paulo Marques, linux-acpi, linux-kernel, kernel-janitors Hi Julia > > > Julia Lawall wrote: > > > > [...] > > > > --- > > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > > index 218b9a1..5306901 100644 > > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > > > fujitsu = acpi_driver_data(device); > > > > > > > > - if (!device || !acpi_driver_data(device)) > > > > - return -EINVAL; > > > > - > > > > > > Shouldn't this still do a: > > > > > > if (!fujitsu) > > > return -EINVAL; > > > > > > to avoid dereferencing a NULL pointer below? > > > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > > test on "device" got in there in the first place. I suspect it came about > > due to some structural changes made a few versions ago and I failed to > > notice that the second check became redundant. > > If you are going to check fujitsu afterwards, then I think there is no > need to test the result of acpi_driver_data before. Yes, of course. I'll wake up soon, promise! So we're left with this. Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 12:10:11.504901871 +0930 @@ -740,12 +740,12 @@ static int acpi_fujitsu_remove(struct ac { struct fujitsu_t *fujitsu = NULL; - if (!device || !acpi_driver_data(device)) + if (!device) return -EINVAL; fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 2:42 ` Jonathan Woithe 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 2:54 UTC (permalink / raw) To: Julia Lawall Cc: Jonathan Woithe, Paulo Marques, linux-acpi, linux-kernel, kernel-janitors Hi Julia > > > Julia Lawall wrote: > > > > [...] > > > > --- > > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > > index 218b9a1..5306901 100644 > > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > > > fujitsu = acpi_driver_data(device); > > > > > > > > - if (!device || !acpi_driver_data(device)) > > > > - return -EINVAL; > > > > - > > > > > > Shouldn't this still do a: > > > > > > if (!fujitsu) > > > return -EINVAL; > > > > > > to avoid dereferencing a NULL pointer below? > > > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > > test on "device" got in there in the first place. I suspect it came about > > due to some structural changes made a few versions ago and I failed to > > notice that the second check became redundant. > > If you are going to check fujitsu afterwards, then I think there is no > need to test the result of acpi_driver_data before. Yes, of course. I'll wake up soon, promise! So we're left with this. Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 12:10:11.504901871 +0930 @@ -740,12 +740,12 @@ static int acpi_fujitsu_remove(struct ac { struct fujitsu_t *fujitsu = NULL; - if (!device || !acpi_driver_data(device)) + if (!device) return -EINVAL; fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 2:42 ` Jonathan Woithe 0 siblings, 0 replies; 16+ messages in thread From: Jonathan Woithe @ 2009-07-29 2:42 UTC (permalink / raw) To: Julia Lawall Cc: Jonathan Woithe, Paulo Marques, linux-acpi, linux-kernel, kernel-janitors Hi Julia > > > Julia Lawall wrote: > > > > [...] > > > > --- > > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > > index 218b9a1..5306901 100644 > > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > > > fujitsu = acpi_driver_data(device); > > > > > > > > - if (!device || !acpi_driver_data(device)) > > > > - return -EINVAL; > > > > - > > > > > > Shouldn't this still do a: > > > > > > if (!fujitsu) > > > return -EINVAL; > > > > > > to avoid dereferencing a NULL pointer below? > > > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > > test on "device" got in there in the first place. I suspect it came about > > due to some structural changes made a few versions ago and I failed to > > notice that the second check became redundant. > > If you are going to check fujitsu afterwards, then I think there is no > need to test the result of acpi_driver_data before. Yes, of course. I'll wake up soon, promise! So we're left with this. Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 12:10:11.504901871 +0930 @@ -740,12 +740,12 @@ static int acpi_fujitsu_remove(struct ac { struct fujitsu_t *fujitsu = NULL; - if (!device || !acpi_driver_data(device)) + if (!device) return -EINVAL; fujitsu = acpi_driver_data(device); - if (!device || !acpi_driver_data(device)) + if (!fujitsu) return -EINVAL; fujitsu->acpi_handle = NULL; Regards jonathan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test 2009-07-29 2:42 ` Jonathan Woithe @ 2009-07-29 4:58 ` Julia Lawall -1 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-29 4:58 UTC (permalink / raw) To: Jonathan Woithe; +Cc: Paulo Marques, linux-acpi, linux-kernel, kernel-janitors On Wed, 29 Jul 2009, Jonathan Woithe wrote: > Hi Julia > > > > > Julia Lawall wrote: > > > > > [...] > > > > > --- > > > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > > > index 218b9a1..5306901 100644 > > > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > > > > > fujitsu = acpi_driver_data(device); > > > > > > > > > > - if (!device || !acpi_driver_data(device)) > > > > > - return -EINVAL; > > > > > - > > > > > > > > Shouldn't this still do a: > > > > > > > > if (!fujitsu) > > > > return -EINVAL; > > > > > > > > to avoid dereferencing a NULL pointer below? > > > > > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > > > test on "device" got in there in the first place. I suspect it came about > > > due to some structural changes made a few versions ago and I failed to > > > notice that the second check became redundant. > > > > If you are going to check fujitsu afterwards, then I think there is no > > need to test the result of acpi_driver_data before. > > Yes, of course. I'll wake up soon, promise! > > So we're left with this. Looks fine now, thanks. julia > Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> > > --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 > +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 12:10:11.504901871 +0930 > @@ -740,12 +740,12 @@ static int acpi_fujitsu_remove(struct ac > { > struct fujitsu_t *fujitsu = NULL; > > - if (!device || !acpi_driver_data(device)) > + if (!device) > return -EINVAL; > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > + if (!fujitsu) > return -EINVAL; > > fujitsu->acpi_handle = NULL; > > > Regards > jonathan > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" 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] 16+ messages in thread
* Re: [PATCH 6/12] drivers/platform/x86: Correct redundant test @ 2009-07-29 4:58 ` Julia Lawall 0 siblings, 0 replies; 16+ messages in thread From: Julia Lawall @ 2009-07-29 4:58 UTC (permalink / raw) To: Jonathan Woithe; +Cc: Paulo Marques, linux-acpi, linux-kernel, kernel-janitors On Wed, 29 Jul 2009, Jonathan Woithe wrote: > Hi Julia > > > > > Julia Lawall wrote: > > > > > [...] > > > > > --- > > > > > drivers/platform/x86/fujitsu-laptop.c | 3 --- > > > > > 1 files changed, 0 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > > > > > index 218b9a1..5306901 100644 > > > > > --- a/drivers/platform/x86/fujitsu-laptop.c > > > > > +++ b/drivers/platform/x86/fujitsu-laptop.c > > > > > @@ -745,9 +745,6 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type) > > > > > > > > > > fujitsu = acpi_driver_data(device); > > > > > > > > > > - if (!device || !acpi_driver_data(device)) > > > > > - return -EINVAL; > > > > > - > > > > > > > > Shouldn't this still do a: > > > > > > > > if (!fujitsu) > > > > return -EINVAL; > > > > > > > > to avoid dereferencing a NULL pointer below? > > > > > > Hmm, yes it should. Well spotted. And I'm not certain how the duplicate > > > test on "device" got in there in the first place. I suspect it came about > > > due to some structural changes made a few versions ago and I failed to > > > notice that the second check became redundant. > > > > If you are going to check fujitsu afterwards, then I think there is no > > need to test the result of acpi_driver_data before. > > Yes, of course. I'll wake up soon, promise! > > So we're left with this. Looks fine now, thanks. julia > Signed-off-by: jwoithe@physics.adelaide.edu.au <Jonathan Woithe> > > --- a/drivers/platform/x86/fujitsu-laptop.c 2009-06-12 19:51:45.333234000 +0930 > +++ b/drivers/platform/x86/fujitsu-laptop.c 2009-07-29 12:10:11.504901871 +0930 > @@ -740,12 +740,12 @@ static int acpi_fujitsu_remove(struct ac > { > struct fujitsu_t *fujitsu = NULL; > > - if (!device || !acpi_driver_data(device)) > + if (!device) > return -EINVAL; > > fujitsu = acpi_driver_data(device); > > - if (!device || !acpi_driver_data(device)) > + if (!fujitsu) > return -EINVAL; > > fujitsu->acpi_handle = NULL; > > > Regards > jonathan > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" 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] 16+ messages in thread
end of thread, other threads:[~2009-07-29 5:01 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-07-27 16:14 [PATCH 6/12] drivers/platform/x86: Correct redundant test Julia Lawall 2009-07-27 16:14 ` Julia Lawall 2009-07-28 17:52 ` Paulo Marques 2009-07-28 17:52 ` Paulo Marques 2009-07-28 20:11 ` Julia Lawall 2009-07-28 20:11 ` Julia Lawall 2009-07-29 0:50 ` Jonathan Woithe 2009-07-29 1:02 ` Jonathan Woithe 2009-07-29 0:50 ` Jonathan Woithe 2009-07-29 2:22 ` Julia Lawall 2009-07-29 2:22 ` Julia Lawall 2009-07-29 2:42 ` Jonathan Woithe 2009-07-29 2:54 ` Jonathan Woithe 2009-07-29 2:42 ` Jonathan Woithe 2009-07-29 4:58 ` Julia Lawall 2009-07-29 4:58 ` Julia Lawall
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.