Message ID | 20201207145446.169978-1-colin.king@canonical.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [next] block/rnbd: fix a null pointer dereference on dev->blk_symlink_name | expand |
On 12/7/20 7:54 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > 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). Applied, thanks.
On Mon, Dec 7, 2020 at 4:01 PM Jens Axboe <axboe@kernel.dk> wrote: > > On 12/7/20 7:54 AM, Colin King wrote: > > From: Colin Ian King <colin.king@canonical.com> > > > > 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). > > Applied, thanks. Thanks Colin for the fix, and thanks Jens for taking care of this. Jack Wang
diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index c3c96a567568..a7caeedeb198 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -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,