| From 888e32b47a3e5dbefc7a38cf4335ba7abf943d58 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Tue, 5 Jun 2018 05:26:33 -0400 |
| Subject: dm: Use kzalloc for all structs with embedded biosets/mempools |
| |
| From: Kent Overstreet <kent.overstreet@gmail.com> |
| |
| [ Upstream commit d377535405686f735b90a8ad4ba269484cd7c96e ] |
| |
| mempool_init()/bioset_init() require that the mempools/biosets be zeroed |
| first; they probably should not _require_ this, but not allocating those |
| structs with kzalloc is a fairly nonsensical thing to do (calling |
| mempool_exit()/bioset_exit() on an uninitialized mempool/bioset is legal |
| and safe, but only works if said memory was zeroed.) |
| |
| Acked-by: Mike Snitzer <snitzer@redhat.com> |
| Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> |
| Signed-off-by: Jens Axboe <axboe@kernel.dk> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/md/dm-bio-prison-v1.c | 2 +- |
| drivers/md/dm-bio-prison-v2.c | 2 +- |
| drivers/md/dm-io.c | 2 +- |
| drivers/md/dm-kcopyd.c | 2 +- |
| drivers/md/dm-region-hash.c | 2 +- |
| drivers/md/dm-snap.c | 2 +- |
| drivers/md/dm-thin.c | 2 +- |
| 7 files changed, 7 insertions(+), 7 deletions(-) |
| |
| diff --git a/drivers/md/dm-bio-prison-v1.c b/drivers/md/dm-bio-prison-v1.c |
| index 874841f0fc837..10532a76688ea 100644 |
| --- a/drivers/md/dm-bio-prison-v1.c |
| +++ b/drivers/md/dm-bio-prison-v1.c |
| @@ -33,7 +33,7 @@ static struct kmem_cache *_cell_cache; |
| */ |
| struct dm_bio_prison *dm_bio_prison_create(void) |
| { |
| - struct dm_bio_prison *prison = kmalloc(sizeof(*prison), GFP_KERNEL); |
| + struct dm_bio_prison *prison = kzalloc(sizeof(*prison), GFP_KERNEL); |
| |
| if (!prison) |
| return NULL; |
| diff --git a/drivers/md/dm-bio-prison-v2.c b/drivers/md/dm-bio-prison-v2.c |
| index 8ce3a1a588cfd..c34ec615420f2 100644 |
| --- a/drivers/md/dm-bio-prison-v2.c |
| +++ b/drivers/md/dm-bio-prison-v2.c |
| @@ -35,7 +35,7 @@ static struct kmem_cache *_cell_cache; |
| */ |
| struct dm_bio_prison_v2 *dm_bio_prison_create_v2(struct workqueue_struct *wq) |
| { |
| - struct dm_bio_prison_v2 *prison = kmalloc(sizeof(*prison), GFP_KERNEL); |
| + struct dm_bio_prison_v2 *prison = kzalloc(sizeof(*prison), GFP_KERNEL); |
| |
| if (!prison) |
| return NULL; |
| diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c |
| index b4357ed4d5416..56e2c0e079d78 100644 |
| --- a/drivers/md/dm-io.c |
| +++ b/drivers/md/dm-io.c |
| @@ -50,7 +50,7 @@ struct dm_io_client *dm_io_client_create(void) |
| struct dm_io_client *client; |
| unsigned min_ios = dm_get_reserved_bio_based_ios(); |
| |
| - client = kmalloc(sizeof(*client), GFP_KERNEL); |
| + client = kzalloc(sizeof(*client), GFP_KERNEL); |
| if (!client) |
| return ERR_PTR(-ENOMEM); |
| |
| diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c |
| index bd9a45b94b552..7ca2b1aaa79d4 100644 |
| --- a/drivers/md/dm-kcopyd.c |
| +++ b/drivers/md/dm-kcopyd.c |
| @@ -892,7 +892,7 @@ struct dm_kcopyd_client *dm_kcopyd_client_create(struct dm_kcopyd_throttle *thro |
| int r = -ENOMEM; |
| struct dm_kcopyd_client *kc; |
| |
| - kc = kmalloc(sizeof(*kc), GFP_KERNEL); |
| + kc = kzalloc(sizeof(*kc), GFP_KERNEL); |
| if (!kc) |
| return ERR_PTR(-ENOMEM); |
| |
| diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c |
| index 85c32b22a420a..91c6f6d72eeec 100644 |
| --- a/drivers/md/dm-region-hash.c |
| +++ b/drivers/md/dm-region-hash.c |
| @@ -179,7 +179,7 @@ struct dm_region_hash *dm_region_hash_create( |
| ; |
| nr_buckets >>= 1; |
| |
| - rh = kmalloc(sizeof(*rh), GFP_KERNEL); |
| + rh = kzalloc(sizeof(*rh), GFP_KERNEL); |
| if (!rh) { |
| DMERR("unable to allocate region hash memory"); |
| return ERR_PTR(-ENOMEM); |
| diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c |
| index 95c564b60d79a..2170f6c118b89 100644 |
| --- a/drivers/md/dm-snap.c |
| +++ b/drivers/md/dm-snap.c |
| @@ -1136,7 +1136,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
| origin_mode = FMODE_WRITE; |
| } |
| |
| - s = kmalloc(sizeof(*s), GFP_KERNEL); |
| + s = kzalloc(sizeof(*s), GFP_KERNEL); |
| if (!s) { |
| ti->error = "Cannot allocate private snapshot structure"; |
| r = -ENOMEM; |
| diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c |
| index aa77959909894..0ee5eae716909 100644 |
| --- a/drivers/md/dm-thin.c |
| +++ b/drivers/md/dm-thin.c |
| @@ -2962,7 +2962,7 @@ static struct pool *pool_create(struct mapped_device *pool_md, |
| return (struct pool *)pmd; |
| } |
| |
| - pool = kmalloc(sizeof(*pool), GFP_KERNEL); |
| + pool = kzalloc(sizeof(*pool), GFP_KERNEL); |
| if (!pool) { |
| *error = "Error allocating memory for pool"; |
| err_p = ERR_PTR(-ENOMEM); |
| -- |
| 2.20.1 |
| |