From: Hyunchul Lee Date: Fri, 9 Jul 2021 08:06:34 +0000 (+0900) Subject: ksmbd: handle error cases first in smb2_create_sd_buffers X-Git-Tag: accepted/tizen/unified/20230118.172025~6553^2~9^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21dd1fd6d718ac59841c3ee3d0b1d82508ef24dc;p=platform%2Fkernel%2Flinux-rpi.git ksmbd: handle error cases first in smb2_create_sd_buffers For code cleanup, handle error cases first in smb2_create_sd_buffers(). Reported-by: Dan Carpenter Signed-off-by: Hyunchul Lee Signed-off-by: Namjae Jeon Signed-off-by: Steve French --- diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index af33d4f..2e266a9 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -2319,25 +2319,23 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, struct path *path) { struct create_context *context; - int rc = -ENOENT; + struct create_sd_buf_req *sd_buf; if (!req->CreateContextsOffset) - return rc; + return -ENOENT; /* Parse SD BUFFER create contexts */ context = smb2_find_context_vals(req, SMB2_CREATE_SD_BUFFER); - if (context && !IS_ERR(context)) { - struct create_sd_buf_req *sd_buf; - - ksmbd_debug(SMB, - "Set ACLs using SMB2_CREATE_SD_BUFFER context\n"); - sd_buf = (struct create_sd_buf_req *)context; - rc = set_info_sec(work->conn, work->tcon, - path, &sd_buf->ntsd, - le32_to_cpu(sd_buf->ccontext.DataLength), true); - } + if (!context) + return -ENOENT; + else if (IS_ERR(context)) + return PTR_ERR(context); - return rc; + ksmbd_debug(SMB, + "Set ACLs using SMB2_CREATE_SD_BUFFER context\n"); + sd_buf = (struct create_sd_buf_req *)context; + return set_info_sec(work->conn, work->tcon, path, &sd_buf->ntsd, + le32_to_cpu(sd_buf->ccontext.DataLength), true); } static void ksmbd_acls_fattr(struct smb_fattr *fattr, struct inode *inode)