linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cifsd: fix an uninitialized variable in smb2_write()
@ 2021-05-11  7:08 ` Dan Carpenter
  2021-05-11  9:10   ` Namjae Jeon
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-05-11  7:08 UTC (permalink / raw)
  To: Namjae Jeon, Marios Makassikis
  Cc: Sergey Senozhatsky, Steve French, Hyunchul Lee, linux-cifs,
	linux-cifsd-devel, kernel-janitors

If there is a permissions problem then the "fp" variable is used in the
"goto out;" without being initialized.  The correct fix is to initialize
"fp" to NULL which turns the ksmbd_fd_put(work, fp); call into a no-op.

Fixes: bb03a3d512bf ("cifsd: Call smb2_set_err_rsp() in smb2_read/smb2_write error path")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/cifsd/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifsd/smb2pdu.c b/fs/cifsd/smb2pdu.c
index d07d7c45f899..18de8a763209 100644
--- a/fs/cifsd/smb2pdu.c
+++ b/fs/cifsd/smb2pdu.c
@@ -6078,7 +6078,7 @@ int smb2_write(struct ksmbd_work *work)
 {
 	struct smb2_write_req *req;
 	struct smb2_write_rsp *rsp, *rsp_org;
-	struct ksmbd_file *fp;
+	struct ksmbd_file *fp = NULL;
 	loff_t offset;
 	size_t length;
 	ssize_t nbytes;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] cifsd: fix an uninitialized variable in smb2_write()
  2021-05-11  7:08 ` [PATCH] cifsd: fix an uninitialized variable in smb2_write() Dan Carpenter
@ 2021-05-11  9:10   ` Namjae Jeon
  0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2021-05-11  9:10 UTC (permalink / raw)
  To: 'Dan Carpenter', 'Marios Makassikis'
  Cc: 'Sergey Senozhatsky', 'Steve French',
	'Hyunchul Lee',
	linux-cifs, linux-cifsd-devel, kernel-janitors

> If there is a permissions problem then the "fp" variable is used in the "goto out;" without being
> initialized.  The correct fix is to initialize "fp" to NULL which turns the ksmbd_fd_put(work, fp);
> call into a no-op.
> 
> Fixes: bb03a3d512bf ("cifsd: Call smb2_set_err_rsp() in smb2_read/smb2_write error path")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Hi Dan,

I have already applied the patch to fix this issue reported by coverity scan.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/fs/cifsd?h=next-20210511&id=9a5549727ad95a574b1d7dc60f663
250fa4b213f

Thanks!
> ---
>  fs/cifsd/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/cifsd/smb2pdu.c b/fs/cifsd/smb2pdu.c index d07d7c45f899..18de8a763209 100644
> --- a/fs/cifsd/smb2pdu.c
> +++ b/fs/cifsd/smb2pdu.c
> @@ -6078,7 +6078,7 @@ int smb2_write(struct ksmbd_work *work)  {
>  	struct smb2_write_req *req;
>  	struct smb2_write_rsp *rsp, *rsp_org;
> -	struct ksmbd_file *fp;
> +	struct ksmbd_file *fp = NULL;
>  	loff_t offset;
>  	size_t length;
>  	ssize_t nbytes;
> --
> 2.30.2



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-11  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210511070900epcas1p1619e7c7f3c6248d4bb871d8e244590ab@epcas1p1.samsung.com>
2021-05-11  7:08 ` [PATCH] cifsd: fix an uninitialized variable in smb2_write() Dan Carpenter
2021-05-11  9:10   ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).