diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2023-01-20 15:08:57 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2023-02-20 20:48:47 +0300 |
commit | d4fba63fe1f78dba749cf7aa04c1dff4b8666eb1 (patch) | |
tree | 243279645b0c5ccd640f9dbe5fd30ad803d44c04 /fs/cifs/smb2ops.c | |
parent | 05844bd661d9fd478df1175b6639bf2d9398becb (diff) | |
download | linux-d4fba63fe1f78dba749cf7aa04c1dff4b8666eb1.tar.xz |
cifs: Get rid of unneeded conditional in the smb2_get_aead_req()
In the smb2_get_aead_req() the skip variable is used only for
the very first iteration of the two nested loops, which means
it's basically in invariant to those loops. Hence, instead of
using conditional on each iteration, unconditionally assign
the 'skip' variable before the loops and at the end of the
inner loop.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2ops.c')
-rw-r--r-- | fs/cifs/smb2ops.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index e6bcd2baf446..157a19f371d6 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -4274,6 +4274,12 @@ static void *smb2_get_aead_req(struct crypto_aead *tfm, const struct smb_rqst *r sg_init_table(*sgl, num_sgs); sg = *sgl; + /* + * The first rqst has a transform header where the + * first 20 bytes are not part of the encrypted blob. + */ + skip = 20; + /* Assumes the first rqst has a transform header as the first iov. * I.e. * rqst[0].rq_iov[0] is transform header @@ -4281,17 +4287,15 @@ static void *smb2_get_aead_req(struct crypto_aead *tfm, const struct smb_rqst *r * rqst[1+].rq_iov[0+] data to be encrypted/decrypted */ for (i = 0; i < num_rqst; i++) { - /* - * The first rqst has a transform header where the - * first 20 bytes are not part of the encrypted blob. - */ for (j = 0; j < rqst[i].rq_nvec; j++) { struct kvec *iov = &rqst[i].rq_iov[j]; - skip = (i == 0) && (j == 0) ? 20 : 0; addr = (unsigned long)iov->iov_base + skip; len = iov->iov_len - skip; sg = cifs_sg_set_buf(sg, (void *)addr, len); + + /* See the above comment on the 'skip' assignment */ + skip = 0; } for (j = 0; j < rqst[i].rq_npages; j++) { rqst_page_get_length(&rqst[i], j, &len, &off); |