nbd: don't leak nbd_config
Subsystems (2)
PATCH 1/1 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
@@ -940,6 +940,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)/* Reset all properties of an NBD device */ static void nbd_reset (struct nbd_device *nbd) { +kfree (nbd->config); nbd->config =NULL ; nbd->tag_set.timeout =0 ;queue_flag_clear_unlocked (QUEUE_FLAG_DISCARD , nbd->disk->queue);
Signature · 1 line
2.4.3
Quoted 8 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(+)
Oops, thanks Ilya
Josef
Quoted 10 lines · Josef Bacik
Quoted 8 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(+)
Quoted 3 lines
Oops, thanks Ilya
Reviewed-by Josef Bacik <[email protected]>
Since config is referenced, why isn't this done in nbd_config_put() instead?
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 10 lines · Josef Bacik
Quoted 8 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(+)
Quoted 6 lines
Quoted 3 lines
Oops, thanks Ilya
Reviewed-by Josef Bacik <[email protected]>Since config is referenced, why isn't this done in
nbd_config_put()instead?
Josef's 5ea8d10802ec added that nbd->config = NULL to nbd_reset(), so I followed his lead. It could be done nbd_config_put() -- nbd_reset() call in nbd_dev_add() looks like a no-op to me. Josef?
Thanks,
Ilya
Josef Bacik
maintainerQuoted 14 lines · Ilya Dryomov
Quoted 13 lines · Jens Axboe
Quoted 12 lines · Josef Bacik
Quoted 8 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(+)Oops, thanks Ilya
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Reviewed-by Josef Bacik <[email protected]>Since config is referenced, why isn't this done in
nbd_config_put()instead?Josef's
5ea8d10802ecadded thatnbd->config= NULL tonbd_reset(), so I followed his lead. It could be donenbd_config_put()--nbd_reset()call innbd_dev_add()looks like a no-op to me. Josef?
Yeah it used to be called more, but when I moved the config to be ref counted it lost it's old uses and I just didn't notice enough to delete it. Just fold that into nbd_config_put() and call it a day. Thanks,
Josef