Skip to content

Commit d377535

Browse files
koverstreetaxboe
authored andcommitted
dm: Use kzalloc for all structs with embedded biosets/mempools
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>
1 parent 0196d6b commit d377535

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

drivers/md/dm-bio-prison-v1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static struct kmem_cache *_cell_cache;
3333
*/
3434
struct dm_bio_prison *dm_bio_prison_create(void)
3535
{
36-
struct dm_bio_prison *prison = kmalloc(sizeof(*prison), GFP_KERNEL);
36+
struct dm_bio_prison *prison = kzalloc(sizeof(*prison), GFP_KERNEL);
3737
int ret;
3838

3939
if (!prison)

drivers/md/dm-bio-prison-v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static struct kmem_cache *_cell_cache;
3535
*/
3636
struct dm_bio_prison_v2 *dm_bio_prison_create_v2(struct workqueue_struct *wq)
3737
{
38-
struct dm_bio_prison_v2 *prison = kmalloc(sizeof(*prison), GFP_KERNEL);
38+
struct dm_bio_prison_v2 *prison = kzalloc(sizeof(*prison), GFP_KERNEL);
3939
int ret;
4040

4141
if (!prison)

drivers/md/dm-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct dm_io_client *dm_io_client_create(void)
5151
unsigned min_ios = dm_get_reserved_bio_based_ios();
5252
int ret;
5353

54-
client = kmalloc(sizeof(*client), GFP_KERNEL);
54+
client = kzalloc(sizeof(*client), GFP_KERNEL);
5555
if (!client)
5656
return ERR_PTR(-ENOMEM);
5757

drivers/md/dm-kcopyd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ struct dm_kcopyd_client *dm_kcopyd_client_create(struct dm_kcopyd_throttle *thro
882882
int r;
883883
struct dm_kcopyd_client *kc;
884884

885-
kc = kmalloc(sizeof(*kc), GFP_KERNEL);
885+
kc = kzalloc(sizeof(*kc), GFP_KERNEL);
886886
if (!kc)
887887
return ERR_PTR(-ENOMEM);
888888

drivers/md/dm-region-hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct dm_region_hash *dm_region_hash_create(
180180
;
181181
nr_buckets >>= 1;
182182

183-
rh = kmalloc(sizeof(*rh), GFP_KERNEL);
183+
rh = kzalloc(sizeof(*rh), GFP_KERNEL);
184184
if (!rh) {
185185
DMERR("unable to allocate region hash memory");
186186
return ERR_PTR(-ENOMEM);

drivers/md/dm-snap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
11201120
origin_mode = FMODE_WRITE;
11211121
}
11221122

1123-
s = kmalloc(sizeof(*s), GFP_KERNEL);
1123+
s = kzalloc(sizeof(*s), GFP_KERNEL);
11241124
if (!s) {
11251125
ti->error = "Cannot allocate private snapshot structure";
11261126
r = -ENOMEM;

drivers/md/dm-thin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ static struct pool *pool_create(struct mapped_device *pool_md,
28612861
return (struct pool *)pmd;
28622862
}
28632863

2864-
pool = kmalloc(sizeof(*pool), GFP_KERNEL);
2864+
pool = kzalloc(sizeof(*pool), GFP_KERNEL);
28652865
if (!pool) {
28662866
*error = "Error allocating memory for pool";
28672867
err_p = ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)