Skip to content

Commit 9850ccd

Browse files
pchelkin91Mike Snitzer
authored andcommitted
dm zoned: free dmz->ddev array in dmz_put_zoned_devices
Commit 4dba128 ("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: 4dba128 ("dm zoned: support arbitrary number of devices") Cc: stable@vger.kernel.org Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent ce9ecca commit 9850ccd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/md/dm-zoned-target.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -748,17 +748,16 @@ static int dmz_get_zoned_device(struct dm_target *ti, char *path,
748748
/*
749749
* Cleanup zoned device information.
750750
*/
751-
static void dmz_put_zoned_device(struct dm_target *ti)
751+
static void dmz_put_zoned_devices(struct dm_target *ti)
752752
{
753753
struct dmz_target *dmz = ti->private;
754754
int i;
755755

756-
for (i = 0; i < dmz->nr_ddevs; i++) {
757-
if (dmz->ddev[i]) {
756+
for (i = 0; i < dmz->nr_ddevs; i++)
757+
if (dmz->ddev[i])
758758
dm_put_device(ti, dmz->ddev[i]);
759-
dmz->ddev[i] = NULL;
760-
}
761-
}
759+
760+
kfree(dmz->ddev);
762761
}
763762

764763
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)
948947
err_meta:
949948
dmz_dtr_metadata(dmz->metadata);
950949
err_dev:
951-
dmz_put_zoned_device(ti);
950+
dmz_put_zoned_devices(ti);
952951
err:
953952
kfree(dmz->dev);
954953
kfree(dmz);
@@ -978,7 +977,7 @@ static void dmz_dtr(struct dm_target *ti)
978977

979978
bioset_exit(&dmz->bio_set);
980979

981-
dmz_put_zoned_device(ti);
980+
dmz_put_zoned_devices(ti);
982981

983982
mutex_destroy(&dmz->chunk_lock);
984983

0 commit comments

Comments
 (0)