Commit 9850ccd5 authored by Fedor Pchelkin's avatar Fedor Pchelkin Committed by Mike Snitzer

dm zoned: free dmz->ddev array in dmz_put_zoned_devices

Commit 4dba1288 ("dm zoned: support arbitrary number of devices")
made the pointers to additional zoned devices to be stored in a
dynamically allocated dmz->ddev array. However, this array is not freed.

Rename dmz_put_zoned_device to dmz_put_zoned_devices and fix it to
free the dmz->ddev array when cleaning up zoned device information.
Remove NULL assignment for all dmz->ddev elements and just free the
dmz->ddev array instead.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 4dba1288 ("dm zoned: support arbitrary number of devices")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent ce9ecca0
...@@ -748,17 +748,16 @@ static int dmz_get_zoned_device(struct dm_target *ti, char *path, ...@@ -748,17 +748,16 @@ static int dmz_get_zoned_device(struct dm_target *ti, char *path,
/* /*
* Cleanup zoned device information. * Cleanup zoned device information.
*/ */
static void dmz_put_zoned_device(struct dm_target *ti) static void dmz_put_zoned_devices(struct dm_target *ti)
{ {
struct dmz_target *dmz = ti->private; struct dmz_target *dmz = ti->private;
int i; int i;
for (i = 0; i < dmz->nr_ddevs; i++) { for (i = 0; i < dmz->nr_ddevs; i++)
if (dmz->ddev[i]) { if (dmz->ddev[i])
dm_put_device(ti, dmz->ddev[i]); dm_put_device(ti, dmz->ddev[i]);
dmz->ddev[i] = NULL;
} kfree(dmz->ddev);
}
} }
static int dmz_fixup_devices(struct dm_target *ti) static int dmz_fixup_devices(struct dm_target *ti)
...@@ -948,7 +947,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -948,7 +947,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
err_meta: err_meta:
dmz_dtr_metadata(dmz->metadata); dmz_dtr_metadata(dmz->metadata);
err_dev: err_dev:
dmz_put_zoned_device(ti); dmz_put_zoned_devices(ti);
err: err:
kfree(dmz->dev); kfree(dmz->dev);
kfree(dmz); kfree(dmz);
...@@ -978,7 +977,7 @@ static void dmz_dtr(struct dm_target *ti) ...@@ -978,7 +977,7 @@ static void dmz_dtr(struct dm_target *ti)
bioset_exit(&dmz->bio_set); bioset_exit(&dmz->bio_set);
dmz_put_zoned_device(ti); dmz_put_zoned_devices(ti);
mutex_destroy(&dmz->chunk_lock); mutex_destroy(&dmz->chunk_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment