mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ye Bin <yebin10@huawei.com>
To: <sfrench@samba.org>, <pc@cjr.nz>, <lsahlber@redhat.com>,
	<sprasad@microsoft.com>, <linux-cifs@vger.kernel.org>
Cc: <samba-technical@lists.samba.org>, <linux-kernel@vger.kernel.org>,
	<yebin10@huawei.com>
Subject: [PATCH -next 1/2] smb3: refactor about 'smb3_init_transform_rq'
Date: Thu, 13 Oct 2022 15:10:34 +0800	[thread overview]
Message-ID: <20221013071035.2890124-2-yebin10@huawei.com> (raw)
In-Reply-To: <20221013071035.2890124-1-yebin10@huawei.com>

Introduce 'orq' and 'nrq' variable for cleanup code. No functional change.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 fs/cifs/smb2ops.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 421be43af425..180f0260cbc4 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -4457,21 +4457,24 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,
 	int rc = -ENOMEM;
 
 	for (i = 1; i < num_rqst; i++) {
-		npages = old_rq[i - 1].rq_npages;
+		struct smb_rqst *orq = old_rq + i - 1;
+		struct smb_rqst *nrq = new_rq + i;
+
+		npages = orq->rq_npages;
 		pages = kmalloc_array(npages, sizeof(struct page *),
 				      GFP_KERNEL);
 		if (!pages)
 			goto err_free;
 
-		new_rq[i].rq_pages = pages;
-		new_rq[i].rq_npages = npages;
-		new_rq[i].rq_offset = old_rq[i - 1].rq_offset;
-		new_rq[i].rq_pagesz = old_rq[i - 1].rq_pagesz;
-		new_rq[i].rq_tailsz = old_rq[i - 1].rq_tailsz;
-		new_rq[i].rq_iov = old_rq[i - 1].rq_iov;
-		new_rq[i].rq_nvec = old_rq[i - 1].rq_nvec;
+		nrq->rq_pages = pages;
+		nrq->rq_npages = npages;
+		nrq->rq_offset = orq->rq_offset;
+		nrq->rq_pagesz = orq->rq_pagesz;
+		nrq->rq_tailsz = orq->rq_tailsz;
+		nrq->rq_iov = orq->rq_iov;
+		nrq->rq_nvec = orq->rq_nvec;
 
-		orig_len += smb_rqst_len(server, &old_rq[i - 1]);
+		orig_len += smb_rqst_len(server, orq);
 
 		for (j = 0; j < npages; j++) {
 			pages[j] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM);
@@ -4484,14 +4487,14 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,
 			char *dst, *src;
 			unsigned int offset, len;
 
-			rqst_page_get_length(&new_rq[i], j, &len, &offset);
+			rqst_page_get_length(nrq, j, &len, &offset);
 
-			dst = (char *) kmap(new_rq[i].rq_pages[j]) + offset;
-			src = (char *) kmap(old_rq[i - 1].rq_pages[j]) + offset;
+			dst = (char *) kmap(nrq->rq_pages[j]) + offset;
+			src = (char *) kmap(orq->rq_pages[j]) + offset;
 
 			memcpy(dst, src, len);
-			kunmap(new_rq[i].rq_pages[j]);
-			kunmap(old_rq[i - 1].rq_pages[j]);
+			kunmap(nrq->rq_pages[j]);
+			kunmap(orq->rq_pages[j]);
 		}
 	}
 
-- 
2.31.1


  reply	other threads:[~2022-10-13  6:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13  7:10 [PATCH -next 0/2] fix potential wild-ptr-deref in 'smb3_free_compound_rqst' Ye Bin
2022-10-13  7:10 ` Ye Bin [this message]
2022-10-13  7:10 ` [PATCH -next 2/2] smb3: " Ye Bin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221013071035.2890124-2-yebin10@huawei.com \
    --to=yebin10@huawei.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=pc@cjr.nz \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®