]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] genhd: NULL checking fix
authorAndrew Morton <akpm@osdl.org>
Tue, 1 Mar 2005 03:47:58 +0000 (19:47 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 1 Mar 2005 03:47:58 +0000 (19:47 -0800)
Avoid a possible null-pointer deref.

Found by the Coverity tool

Signed-off-by: Alexander Nyberg <alexn@dsv.su.se>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/block/genhd.c

index aee126315447c70c51fe5b59f7a144ba059bce95..80da35816f5e284e43eb8e64d76bf04c8e67f76f 100644 (file)
@@ -660,9 +660,10 @@ int invalidate_partition(struct gendisk *disk, int index)
 {
        int res = 0;
        struct block_device *bdev = bdget_disk(disk, index);
-       if (bdev)
+       if (bdev) {
                res = __invalidate_device(bdev, 1);
-       bdput(bdev);
+               bdput(bdev);
+       }
        return res;
 }