nbd: nbd_reset() call in nbd_dev_add() is redundant
Subsystems (2)
PATCH v2 1/2 nbd: nbd_reset() call in nbd_dev_add() is redundant
There is nothing to clear -- nbd_device has just been allocated. Fold nbd_reset() into its other caller, nbd_config_put().
--- drivers/block/nbd.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/block/nbd.c +4 -10
@@ -937,14 +937,6 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)return -ENOSPC ; } -/* Reset all properties of an NBD device */ -static void nbd_reset (struct nbd_device *nbd) -{ - nbd->config =NULL ; - nbd->tag_set.timeout =0 ; -queue_flag_clear_unlocked (QUEUE_FLAG_DISCARD , nbd->disk->queue); -} -static void nbd_bdev_reset (struct block_device *bdev) {if (bdev->bd_openers >1 )
@@ -1029,7 +1021,10 @@ static void nbd_config_put(struct nbd_device *nbd) }kfree (config->socks); } -nbd_reset (nbd); + nbd->config =NULL ; + + nbd->tag_set.timeout =0 ; +queue_flag_clear_unlocked (QUEUE_FLAG_DISCARD , nbd->disk->queue);mutex_unlock (&nbd->config_lock);nbd_put (nbd);
@@ -1483,7 +1478,6 @@ static int nbd_dev_add(int index) disk->fops = &nbd_fops; disk->private_data = nbd;sprintf (disk->disk_name,"nbd%d" , index); -nbd_reset (nbd);add_disk (disk); nbd_total_devices++;return index;
Signature · 1 line
2.4.3
PATCH v2 2/2 nbd: don't leak nbd_config
nbd_config is allocated in nbd_alloc_config(), but never freed.
--- drivers/block/nbd.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/nbd.c +1 -0
@@ -1021,6 +1021,7 @@ static void nbd_config_put(struct nbd_device *nbd) }kfree (config->socks); } +kfree (nbd->config); nbd->config =NULL ; nbd->tag_set.timeout =0 ;
Signature · 1 line
2.4.3
Re: [PATCH v2 2/2] nbd: don't leak nbd_config
Quoted 13 lines · Ilya Dryomov
nbd_configis allocated innbd_alloc_config(), but never freed.Fixes 5ea8d10802ec ("nbd: separate out the config information")Signed-off-by Ilya Dryomov <[email protected]>--- drivers/block/nbd.c | 1 + 1 file changed, 1 insertion(+)drivers/block/nbd.c +0
-0
drivers/block/nbd.c static void nbd_config_put(struct nbd_device *nbd) · line 1027
Quoted 7 lines
drivers/block/nbd.c +1
-0@@ -1021,6 +1021,7 @@ static void nbd_config_put(struct nbd_device *nbd) }kfree (config->socks); } +kfree (nbd->config); nbd->config =NULL ; nbd->tag_set.timeout =0 ;
Hi Josef,
Ping -- I think these should go into 4.12-rc, Jens is probably waiting for your OK.
Thanks,
Ilya
Quoted 4 lines · Ilya Dryomov
There is nothing to clear --
nbd_devicehas just been allocated. Foldnbd_reset()into its other caller,nbd_config_put().Signed-off-by Ilya Dryomov <[email protected]>
Thanks,
Josef
Re: [PATCH v2 2/2] nbd: don't leak nbd_config
In reply to Ilya DryomovQuoted 4 lines · Ilya Dryomov
nbd_configis allocated innbd_alloc_config(), but never freed.Fixes 5ea8d10802ec ("nbd: separate out the config information")Signed-off-by Ilya Dryomov <[email protected]>
Thanks,
Josef
Jens Axboe
maintainerQuoted 2 lines · Ilya Dryomov
There is nothing to clear --
nbd_devicehas just been allocated. Foldnbd_reset()into its other caller,nbd_config_put().
Added 1+2 for 4.12.
Signature · 1 line
Jens Axboe