Skip to content

Commit

Permalink
block/rnbd: fix a null pointer dereference on dev->blk_symlink_name
Browse files Browse the repository at this point in the history
Currently in the case where dev->blk_symlink_name fails to be allocates
the error return path attempts to set an end-of-string character to
the unallocated dev->blk_symlink_name causing a null pointer dereference
error. Fix this by returning with an explicity ENOMEM error (which also
is missing in the original code as was not initialized).

Fixes: 1eb54f8 ("block/rnbd: client: sysfs interface functions")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Addresses-Coverity: ("Dereference after null check")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Colin Ian King authored and Jens Axboe committed Dec 7, 2020
1 parent 64e8a6e commit 733c15b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/block/rnbd/rnbd-clt-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static int rnbd_clt_add_dev_symlink(struct rnbd_clt_dev *dev)
dev->blk_symlink_name = kzalloc(len, GFP_KERNEL);
if (!dev->blk_symlink_name) {
rnbd_clt_err(dev, "Failed to allocate memory for blk_symlink_name\n");
goto out_err;
return -ENOMEM;
}

ret = rnbd_clt_get_path_name(dev, dev->blk_symlink_name,
Expand Down

0 comments on commit 733c15b

Please sign in to comment.