Skip to content

Commit

Permalink
smb/client: Prevent error pointer dereference
Browse files Browse the repository at this point in the history
The cifs_sb_tlink() function can return error pointers, but this code
dereferences it before checking for error pointers.  Re-order the code
to fix that.

Fixes: 0f9b6b045bb2 ("fs/smb/client: implement chmod() for SMB3 POSIX Extensions")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Dan Carpenter authored and Steve French committed Nov 21, 2024
1 parent d413eab commit 7a2158b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/smb/client/cifsacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,14 +1592,16 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
struct smb_ntsd *pntsd = NULL; /* acl obtained from server */
struct smb_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct tcon_link *tlink;
struct smb_version_operations *ops;
bool mode_from_sid, id_from_sid;
bool posix = tlink_tcon(tlink)->posix_extensions;
const u32 info = 0;
bool posix;

tlink = cifs_sb_tlink(cifs_sb);
if (IS_ERR(tlink))
return PTR_ERR(tlink);
posix = tlink_tcon(tlink)->posix_extensions;

ops = tlink_tcon(tlink)->ses->server->ops;

Expand Down

0 comments on commit 7a2158b

Please sign in to comment.