Patchwork cifs: initialize nbytes at the beginning of CIFSSMBWrite()

login
register
mail settings
Submitter Suresh Jayaraman
Date March 30, 2010, 5:34 p.m.
Message ID <1269970492-5356-1-git-send-email-sjayaraman@suse.de>
Download mbox | patch
Permalink /patch/48997/
State New
Headers show

Comments

Suresh Jayaraman - March 30, 2010, 5:34 p.m.
By doing this we always overwrite nbytes value that is being passed on to
CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
doing this already.

I have not Cc-ed -stable, please do so if required.


Cc: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Reviewed-by: Jeff Layton <jlayton@samba.org>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
 fs/cifs/cifssmb.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 7cc7f83..64c2b60 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1430,6 +1430,8 @@  CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 	__u32 bytes_sent;
 	__u16 byte_count;
 
+	*nbytes = 0;
+
 	/* cFYI(1, ("write at %lld %d bytes", offset, count));*/
 	if (tcon->ses == NULL)
 		return -ECONNABORTED;
@@ -1510,10 +1512,9 @@  CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, long_op);
 	cifs_stats_inc(&tcon->num_writes);
-	if (rc) {
+	if (rc)
 		cFYI(1, ("Send error in write = %d", rc));
-		*nbytes = 0;
-	} else {
+	else {
 		*nbytes = le16_to_cpu(pSMBr->CountHigh);
 		*nbytes = (*nbytes) << 16;
 		*nbytes += le16_to_cpu(pSMBr->Count);