* [bug report] cifs: improve symlink handling for smb2+
@ 2022-10-14 9:37 Dan Carpenter
2022-10-14 16:40 ` [PATCH] cifs: fix static checker warning Paulo Alcantara
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-10-14 9:37 UTC (permalink / raw)
To: pc; +Cc: linux-cifs
Hello Paulo Alcantara,
This is a semi-automatic email about new static checker warnings.
The patch d87ee26fa912: "cifs: improve symlink handling for smb2+"
from Oct 3, 2022, leads to the following Smatch complaint:
fs/cifs/smb2file.c:126 smb2_open_file()
warn: variable dereferenced before check 'oparms->cifs_sb' (see line 112)
fs/cifs/smb2file.c
111
112 smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
^^^^^^^^^^^^^^^
The existing code dereferences "oparms->cifs_sb" without checking for
NULL
113 if (smb2_path == NULL)
114 return -ENOMEM;
115
116 oparms->desired_access |= FILE_READ_ATTRIBUTES;
117 smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
118
119 rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
120 &err_buftype);
121 if (rc && data) {
122 struct smb2_hdr *hdr = err_iov.iov_base;
123
124 if (unlikely(!err_iov.iov_base || err_buftype == CIFS_NO_BUFFER))
125 rc = -ENOMEM;
126 else if (hdr->Status == STATUS_STOPPED_ON_SYMLINK && oparms->cifs_sb) {
^^^^^^^^^^^^^^^
so presumably this new NULL check can be deleted as well.
127 rc = smb2_parse_symlink_response(oparms->cifs_sb, &err_iov,
128 &data->symlink_target);
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] cifs: fix static checker warning
2022-10-14 9:37 [bug report] cifs: improve symlink handling for smb2+ Dan Carpenter
@ 2022-10-14 16:40 ` Paulo Alcantara
0 siblings, 0 replies; 2+ messages in thread
From: Paulo Alcantara @ 2022-10-14 16:40 UTC (permalink / raw)
To: Dan Carpenter, pc; +Cc: linux-cifs
Remove unnecessary NULL check of oparam->cifs_sb when parsing symlink
error response as it's already set by all smb2_open_file() callers and
deferenced earlier.
This fixes below report:
fs/cifs/smb2file.c:126 smb2_open_file()
warn: variable dereferenced before check 'oparms->cifs_sb' (see line 112)
Link: https://lore.kernel.org/r/Y0kt42j2tdpYakRu@kili
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
---
fs/cifs/smb2file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
index 4992b43616a7..ffbd9a99fc12 100644
--- a/fs/cifs/smb2file.c
+++ b/fs/cifs/smb2file.c
@@ -123,7 +123,7 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
if (unlikely(!err_iov.iov_base || err_buftype == CIFS_NO_BUFFER))
rc = -ENOMEM;
- else if (hdr->Status == STATUS_STOPPED_ON_SYMLINK && oparms->cifs_sb) {
+ else if (hdr->Status == STATUS_STOPPED_ON_SYMLINK) {
rc = smb2_parse_symlink_response(oparms->cifs_sb, &err_iov,
&data->symlink_target);
if (!rc) {
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-14 16:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-14 9:37 [bug report] cifs: improve symlink handling for smb2+ Dan Carpenter
2022-10-14 16:40 ` [PATCH] cifs: fix static checker warning Paulo Alcantara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox