Commit 2b1116bb authored by Markus Elfring's avatar Markus Elfring Committed by Steve French

CIFS: Use common error handling code in smb2_ioctl_query_info()

Move the same error code assignments so that such exception handling
can be better reused at the end of this function.

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent cfaa1181
...@@ -1524,35 +1524,32 @@ smb2_ioctl_query_info(const unsigned int xid, ...@@ -1524,35 +1524,32 @@ smb2_ioctl_query_info(const unsigned int xid,
if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length) if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length)
qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount); qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount);
if (qi.input_buffer_length > 0 && if (qi.input_buffer_length > 0 &&
le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length > rsp_iov[1].iov_len) { le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length
rc = -EFAULT; > rsp_iov[1].iov_len)
goto iqinf_exit; goto e_fault;
}
if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, if (copy_to_user(&pqi->input_buffer_length,
sizeof(qi.input_buffer_length))) { &qi.input_buffer_length,
rc = -EFAULT; sizeof(qi.input_buffer_length)))
goto iqinf_exit; goto e_fault;
}
if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info), if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info),
(const void *)io_rsp + le32_to_cpu(io_rsp->OutputOffset), (const void *)io_rsp + le32_to_cpu(io_rsp->OutputOffset),
qi.input_buffer_length)) { qi.input_buffer_length))
rc = -EFAULT; goto e_fault;
goto iqinf_exit;
}
} else { } else {
pqi = (struct smb_query_info __user *)arg; pqi = (struct smb_query_info __user *)arg;
qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;
if (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length) if (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length)
qi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength); qi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength);
if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, if (copy_to_user(&pqi->input_buffer_length,
sizeof(qi.input_buffer_length))) { &qi.input_buffer_length,
rc = -EFAULT; sizeof(qi.input_buffer_length)))
goto iqinf_exit; goto e_fault;
}
if (copy_to_user(pqi + 1, qi_rsp->Buffer, qi.input_buffer_length)) { if (copy_to_user(pqi + 1, qi_rsp->Buffer,
rc = -EFAULT; qi.input_buffer_length))
goto iqinf_exit; goto e_fault;
}
} }
iqinf_exit: iqinf_exit:
...@@ -1568,6 +1565,10 @@ smb2_ioctl_query_info(const unsigned int xid, ...@@ -1568,6 +1565,10 @@ smb2_ioctl_query_info(const unsigned int xid,
free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base); free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
return rc; return rc;
e_fault:
rc = -EFAULT;
goto iqinf_exit;
} }
static ssize_t static ssize_t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment