block/rnbd-clt: Fix possible memleak
authorJack Wang <jinpu.wang@cloud.ionos.com>
Thu, 10 Dec 2020 10:18:21 +0000 (11:18 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 16 Dec 2020 14:19:59 +0000 (07:19 -0700)
commit8b1282f52175918a1307a00a4e725bcc516b74b7
treee17ce916a3224cba332ec52d74f8bb1074b52b02
parentfdba53782df38292168a8dd9f8f3d2304731048a
block/rnbd-clt: Fix possible memleak

In error case, we do not free the memory for blk_symlink_name.

Do it by free the memory in error case, and set to NULL
afterwards.

Also fix the condition in rnbd_clt_remove_dev_symlink.

Fixes: 64e8a6ece1a5 ("block/rnbd-clt: Dynamically alloc buffer for pathname & blk_symlink_name")
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Reviewed-by: Md Haris Iqbal <haris.iqbal@cloud.ionos.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/rnbd/rnbd-clt-sysfs.c