Skip to content

Commit 49afa55

Browse files
Julia Lawalldavem330
authored andcommitted
net/caif: Use kzalloc
Use kzalloc rather than the combination of kmalloc and memset. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression x,size,flags; statement S; @@ -x = kmalloc(size,flags); +x = kzalloc(size,flags); if (x == NULL) S -memset(x, 0, size); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent beae22e commit 49afa55

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

‎net/caif/cfcnfg.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ struct cfcnfg *cfcnfg_create(void)
6565
struct cfcnfg *this;
6666
struct cfctrl_rsp *resp;
6767
/* Initiate this layer */
68-
this = kmalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
68+
this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
6969
if (!this) {
7070
pr_warning("CAIF: %s(): Out of memory\n", __func__);
7171
return NULL;
7272
}
73-
memset(this, 0, sizeof(struct cfcnfg));
7473
this->mux = cfmuxl_create();
7574
if (!this->mux)
7675
goto out_of_mem;

‎net/caif/cfctrl.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,11 @@ int cfctrl_linkup_request(struct cflayer *layer,
284284
__func__, param->linktype);
285285
return -EINVAL;
286286
}
287-
req = kmalloc(sizeof(*req), GFP_KERNEL);
287+
req = kzalloc(sizeof(*req), GFP_KERNEL);
288288
if (!req) {
289289
pr_warning("CAIF: %s(): Out of memory\n", __func__);
290290
return -ENOMEM;
291291
}
292-
memset(req, 0, sizeof(*req));
293292
req->client_layer = user_layer;
294293
req->cmd = CFCTRL_CMD_LINK_SETUP;
295294
req->param = *param;

0 commit comments

Comments
 (0)