Message ID | 20220312102705.71413-2-Julia.Lawall@inria.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | use kzalloc | expand |
Which tree should this be merged from? cifs-2.6.git for-next ... or do you prefer that these all go together through a different tree On Sun, Mar 13, 2022 at 11:36 AM Julia Lawall <Julia.Lawall@inria.fr> wrote: > > Use kzalloc instead of kmalloc + memset. > > The semantic patch that makes this change is: > (https://coccinelle.gitlabpages.inria.fr/website/) > > //<smpl> > @@ > expression res, size, flag; > @@ > - res = kmalloc(size, flag); > + res = kzalloc(size, flag); > ... > - memset(res, 0, size); > //</smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> > > --- > fs/cifs/transport.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > index eeb1a699bd6f..4ff8e165a180 100644 > --- a/fs/cifs/transport.c > +++ b/fs/cifs/transport.c > @@ -464,13 +464,12 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, > return -EIO; > } > > - tr_hdr = kmalloc(sizeof(*tr_hdr), GFP_NOFS); > + tr_hdr = kzalloc(sizeof(*tr_hdr), GFP_NOFS); > if (!tr_hdr) > return -ENOMEM; > > memset(&cur_rqst[0], 0, sizeof(cur_rqst)); > memset(&iov, 0, sizeof(iov)); > - memset(tr_hdr, 0, sizeof(*tr_hdr)); > > iov.iov_base = tr_hdr; > iov.iov_len = sizeof(*tr_hdr); >
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index eeb1a699bd6f..4ff8e165a180 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -464,13 +464,12 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, return -EIO; } - tr_hdr = kmalloc(sizeof(*tr_hdr), GFP_NOFS); + tr_hdr = kzalloc(sizeof(*tr_hdr), GFP_NOFS); if (!tr_hdr) return -ENOMEM; memset(&cur_rqst[0], 0, sizeof(cur_rqst)); memset(&iov, 0, sizeof(iov)); - memset(tr_hdr, 0, sizeof(*tr_hdr)); iov.iov_base = tr_hdr; iov.iov_len = sizeof(*tr_hdr);
Use kzalloc instead of kmalloc + memset. The semantic patch that makes this change is: (https://coccinelle.gitlabpages.inria.fr/website/) //<smpl> @@ expression res, size, flag; @@ - res = kmalloc(size, flag); + res = kzalloc(size, flag); ... - memset(res, 0, size); //</smpl> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> --- fs/cifs/transport.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)