Message ID | 567c75570345fee506fb56d0c13cf9369931100a.1662009844.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] nfsd: Fix a memory leak in an error handling path | expand |
On Thu, 2022-09-01 at 07:27 +0200, Christophe JAILLET wrote: > memdup_user() can't return NULL, so there is no point for checking for it. > > Simplify some tests accordingly. > > Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > fs/nfsd/nfs4recover.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c > index 248ff9f4141c..2968cf604e3b 100644 > --- a/fs/nfsd/nfs4recover.c > +++ b/fs/nfsd/nfs4recover.c > @@ -807,7 +807,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, > if (get_user(namelen, &ci->cc_name.cn_len)) > return -EFAULT; > name.data = memdup_user(&ci->cc_name.cn_id, namelen); > - if (IS_ERR_OR_NULL(name.data)) > + if (IS_ERR(name.data)) > return -EFAULT; > name.len = namelen; > get_user(princhashlen, &ci->cc_princhash.cp_len); > @@ -815,7 +815,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, > princhash.data = memdup_user( > &ci->cc_princhash.cp_data, > princhashlen); > - if (IS_ERR_OR_NULL(princhash.data)) { > + if (IS_ERR(princhash.data)) { > kfree(name.data); > return -EFAULT; > } > @@ -829,7 +829,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, > if (get_user(namelen, &cnm->cn_len)) > return -EFAULT; > name.data = memdup_user(&cnm->cn_id, namelen); > - if (IS_ERR_OR_NULL(name.data)) > + if (IS_ERR(name.data)) > return -EFAULT; > name.len = namelen; > } Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 248ff9f4141c..2968cf604e3b 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -807,7 +807,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, if (get_user(namelen, &ci->cc_name.cn_len)) return -EFAULT; name.data = memdup_user(&ci->cc_name.cn_id, namelen); - if (IS_ERR_OR_NULL(name.data)) + if (IS_ERR(name.data)) return -EFAULT; name.len = namelen; get_user(princhashlen, &ci->cc_princhash.cp_len); @@ -815,7 +815,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, princhash.data = memdup_user( &ci->cc_princhash.cp_data, princhashlen); - if (IS_ERR_OR_NULL(princhash.data)) { + if (IS_ERR(princhash.data)) { kfree(name.data); return -EFAULT; } @@ -829,7 +829,7 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, if (get_user(namelen, &cnm->cn_len)) return -EFAULT; name.data = memdup_user(&cnm->cn_id, namelen); - if (IS_ERR_OR_NULL(name.data)) + if (IS_ERR(name.data)) return -EFAULT; name.len = namelen; }
memdup_user() can't return NULL, so there is no point for checking for it. Simplify some tests accordingly. Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- fs/nfsd/nfs4recover.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)