Skip to content

Commit

Permalink
[S390] drivers/s390: put NULL test before dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Martin Schwidefsky committed Aug 23, 2009
1 parent 06739a8 commit cf05b82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/s390/block/dasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,9 @@ static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
struct dasd_device *base;

block = bdev->bd_disk->private_data;
base = block->base;
if (!block)
return -ENODEV;
base = block->base;

if (!base->discipline ||
!base->discipline->fill_geometry)
Expand Down

0 comments on commit cf05b82

Please sign in to comment.