[PATCH] RapidIO: fix potential null deref in rio_setup_device()

Alexandre Bounine alexandre.bounine at idt.com
Wed Sep 7 04:44:15 EST 2011


The "goto cleanup" path can deference "rswitch" when it is NULL.

Reported-by: Dan Carpenter <error27 at gmail.com>
Signed-off-by: Alexandre Bounine <alexandre.bounine at idt.com>
Cc: Dan Carpenter <error27 at gmail.com>
Cc: Kumar Gala <galak at kernel.crashing.org>
Cc: Matt Porter <mporter at kernel.crashing.org>
Cc: Chul Kim <chul.kim at idt.com>
---
 drivers/rapidio/rio-scan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index ebe77dd..5b2cb53 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -516,7 +516,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
 	return rdev;
 
 cleanup:
-	if (rio_is_switch(rdev))
+	if (rswitch)
 		kfree(rswitch->route_table);
 
 	kfree(rdev);
-- 
1.7.6



More information about the Linuxppc-dev mailing list