Skip to content

Commit 032137f

Browse files
Paulo Alcantarasmfrench
authored andcommitted
smb: client: fix warning in CIFSFindFirst()
This fixes the following warning reported by kernel test robot fs/smb/client/cifssmb.c:4089 CIFSFindFirst() warn: missing error code? 'rc' Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e8eeca0 commit 032137f

File tree

1 file changed

+44
-54
lines changed

1 file changed

+44
-54
lines changed

fs/smb/client/cifssmb.c

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,11 +3958,12 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
39583958
TRANSACTION2_FFIRST_REQ *pSMB = NULL;
39593959
TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
39603960
T2_FFIRST_RSP_PARMS *parms;
3961-
int rc = 0;
3961+
struct nls_table *nls_codepage;
3962+
unsigned int lnoff;
3963+
__u16 params, byte_count;
39623964
int bytes_returned = 0;
39633965
int name_len, remap;
3964-
__u16 params, byte_count;
3965-
struct nls_table *nls_codepage;
3966+
int rc = 0;
39663967

39673968
cifs_dbg(FYI, "In FindFirst for %s\n", searchName);
39683969

@@ -4043,63 +4044,52 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
40434044
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
40444045
cifs_stats_inc(&tcon->stats.cifs_stats.num_ffirst);
40454046

4046-
if (rc) {/* BB add logic to retry regular search if Unix search
4047-
rejected unexpectedly by server */
4048-
/* BB Add code to handle unsupported level rc */
4047+
if (rc) {
4048+
/*
4049+
* BB: add logic to retry regular search if Unix search rejected
4050+
* unexpectedly by server.
4051+
*/
4052+
/* BB: add code to handle unsupported level rc */
40494053
cifs_dbg(FYI, "Error in FindFirst = %d\n", rc);
4050-
40514054
cifs_buf_release(pSMB);
4052-
4053-
/* BB eventually could optimize out free and realloc of buf */
4054-
/* for this case */
4055+
/*
4056+
* BB: eventually could optimize out free and realloc of buf for
4057+
* this case.
4058+
*/
40554059
if (rc == -EAGAIN)
40564060
goto findFirstRetry;
4057-
} else { /* decode response */
4058-
/* BB remember to free buffer if error BB */
4059-
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
4060-
if (rc == 0) {
4061-
unsigned int lnoff;
4062-
4063-
if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
4064-
psrch_inf->unicode = true;
4065-
else
4066-
psrch_inf->unicode = false;
4067-
4068-
psrch_inf->ntwrk_buf_start = (char *)pSMBr;
4069-
psrch_inf->smallBuf = false;
4070-
psrch_inf->srch_entries_start =
4071-
(char *) &pSMBr->hdr.Protocol +
4072-
le16_to_cpu(pSMBr->t2.DataOffset);
4073-
parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
4074-
le16_to_cpu(pSMBr->t2.ParameterOffset));
4075-
4076-
if (parms->EndofSearch)
4077-
psrch_inf->endOfSearch = true;
4078-
else
4079-
psrch_inf->endOfSearch = false;
4080-
4081-
psrch_inf->entries_in_buffer =
4082-
le16_to_cpu(parms->SearchCount);
4083-
psrch_inf->index_of_last_entry = 2 /* skip . and .. */ +
4084-
psrch_inf->entries_in_buffer;
4085-
lnoff = le16_to_cpu(parms->LastNameOffset);
4086-
if (CIFSMaxBufSize < lnoff) {
4087-
cifs_dbg(VFS, "ignoring corrupt resume name\n");
4088-
psrch_inf->last_entry = NULL;
4089-
return rc;
4090-
}
4091-
4092-
psrch_inf->last_entry = psrch_inf->srch_entries_start +
4093-
lnoff;
4094-
4095-
if (pnetfid)
4096-
*pnetfid = parms->SearchHandle;
4097-
} else {
4098-
cifs_buf_release(pSMB);
4099-
}
4061+
return rc;
4062+
}
4063+
/* decode response */
4064+
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
4065+
if (rc) {
4066+
cifs_buf_release(pSMB);
4067+
return rc;
41004068
}
41014069

4102-
return rc;
4070+
psrch_inf->unicode = !!(pSMBr->hdr.Flags2 & SMBFLG2_UNICODE);
4071+
psrch_inf->ntwrk_buf_start = (char *)pSMBr;
4072+
psrch_inf->smallBuf = false;
4073+
psrch_inf->srch_entries_start = (char *)&pSMBr->hdr.Protocol +
4074+
le16_to_cpu(pSMBr->t2.DataOffset);
4075+
4076+
parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +
4077+
le16_to_cpu(pSMBr->t2.ParameterOffset));
4078+
psrch_inf->endOfSearch = !!parms->EndofSearch;
4079+
4080+
psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount);
4081+
psrch_inf->index_of_last_entry = 2 /* skip . and .. */ +
4082+
psrch_inf->entries_in_buffer;
4083+
lnoff = le16_to_cpu(parms->LastNameOffset);
4084+
if (CIFSMaxBufSize < lnoff) {
4085+
cifs_dbg(VFS, "ignoring corrupt resume name\n");
4086+
psrch_inf->last_entry = NULL;
4087+
} else {
4088+
psrch_inf->last_entry = psrch_inf->srch_entries_start + lnoff;
4089+
if (pnetfid)
4090+
*pnetfid = parms->SearchHandle;
4091+
}
4092+
return 0;
41034093
}
41044094

41054095
int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,

0 commit comments

Comments
 (0)