Skip to contentSkip to conversation

bcache: Fix error handling in init code

DISCUSSION Dan Carpenter 1 participant 1 message Jul 7, 2014 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

Hello Kent Overstreet,

This is a semi-automatic email about new static checker warnings.

The patch f59fce847fc8: "bcache: Fix error handling in init code" from May 15, 2013, leads to the following Smatch complaint:

drivers/md/bcache/super.c:1088 cached_dev_free()

	 error: we previously assumed 'dc->bdev->bd_disk' could be null (see line 1085)

drivers/md/bcache/super.c
1084 if (!IS_ERR_OR_NULL(dc->bdev)) {
1085 if (dc->bdev->bd_disk)

                            ^^^^^^^^^^^^^^^^^

The patch introduces a new check.

  1086				blk_sync_queue(bdev_get_queue(dc->bdev));
  1087	
  1088			blkdev_put(dc->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);

But "dc->bdev->bd_disk" is dereferenced inside the call to blkdev_put().

1089 }
1090

regards,
dan carpenter