mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 5/14] drivers/acpi: Move dereference after NULL test
@ 2009-10-17  6:34 Julia Lawall
  2009-11-05 22:30 ` Len Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-10-17  6:34 UTC (permalink / raw)
  To: Len Brown, linux-acpi, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

If the NULL test on pr is needed, then the dereference should be after the
NULL test.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/acpi/processor_throttling.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 4c6c14c..1c5d7a8 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -1133,15 +1133,15 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
 	int result = 0;
 	struct acpi_processor_throttling *pthrottling;
 
+	if (!pr)
+		return -EINVAL;
+
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 			  "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
 			  pr->throttling.address,
 			  pr->throttling.duty_offset,
 			  pr->throttling.duty_width));
 
-	if (!pr)
-		return -EINVAL;
-
 	/*
 	 * Evaluate _PTC, _TSS and _TPC
 	 * They must all be present or none of them can be used.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 5/14] drivers/acpi: Move dereference after NULL test
  2009-10-17  6:34 [PATCH 5/14] drivers/acpi: Move dereference after NULL test Julia Lawall
@ 2009-11-05 22:30 ` Len Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2009-11-05 22:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-acpi, linux-kernel, kernel-janitors

applied

thanks,
Len Brown, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-05 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-17  6:34 [PATCH 5/14] drivers/acpi: Move dereference after NULL test Julia Lawall
2009-11-05 22:30 ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®