RapidIO: fix potential null deref in rio_setup_device()
authorAlexandre Bounine <alexandre.bounine@idt.com>
Wed, 2 Nov 2011 20:39:11 +0000 (13:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Nov 2011 23:07:01 +0000 (16:07 -0700)
The "goto cleanup" path can deference "rswitch" when it is NULL.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Chul Kim <chul.kim@idt.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rapidio/rio-scan.c

index 0914f49..2bebd79 100644 (file)
@@ -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);