瀏覽代碼

[S390] drivers/s390: put NULL test before dereference

If the NULL test on block is needed, it should be before the dereference of
the base field.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
expression E1,E2;
identifier fld;
statement S1,S2;
@@

E1 = E2->fld;
(
if (E1 == NULL) S1 else S2
|
*if (E2 == NULL) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Julia Lawall 16 年之前
父節點
當前提交
cf05b824db
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/s390/block/dasd.c

+ 1 - 1
drivers/s390/block/dasd.c

@@ -2135,9 +2135,9 @@ static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 	struct dasd_device *base;
 	struct dasd_device *base;
 
 
 	block = bdev->bd_disk->private_data;
 	block = bdev->bd_disk->private_data;
-	base = block->base;
 	if (!block)
 	if (!block)
 		return -ENODEV;
 		return -ENODEV;
+	base = block->base;
 
 
 	if (!base->discipline ||
 	if (!base->discipline ||
 	    !base->discipline->fill_geometry)
 	    !base->discipline->fill_geometry)