Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Markus Elfring and committed by
Steve French
2b1116bb cfaa1181

+23 -22
+23 -22
fs/cifs/smb2ops.c
··· 1524 1524 if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length) 1525 1525 qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount); 1526 1526 if (qi.input_buffer_length > 0 && 1527 - le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length > rsp_iov[1].iov_len) { 1528 - rc = -EFAULT; 1529 - goto iqinf_exit; 1530 - } 1531 - if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, 1532 - sizeof(qi.input_buffer_length))) { 1533 - rc = -EFAULT; 1534 - goto iqinf_exit; 1535 - } 1527 + le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length 1528 + > rsp_iov[1].iov_len) 1529 + goto e_fault; 1530 + 1531 + if (copy_to_user(&pqi->input_buffer_length, 1532 + &qi.input_buffer_length, 1533 + sizeof(qi.input_buffer_length))) 1534 + goto e_fault; 1535 + 1536 1536 if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info), 1537 1537 (const void *)io_rsp + le32_to_cpu(io_rsp->OutputOffset), 1538 - qi.input_buffer_length)) { 1539 - rc = -EFAULT; 1540 - goto iqinf_exit; 1541 - } 1538 + qi.input_buffer_length)) 1539 + goto e_fault; 1542 1540 } else { 1543 1541 pqi = (struct smb_query_info __user *)arg; 1544 1542 qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; 1545 1543 if (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length) 1546 1544 qi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength); 1547 - if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, 1548 - sizeof(qi.input_buffer_length))) { 1549 - rc = -EFAULT; 1550 - goto iqinf_exit; 1551 - } 1552 - if (copy_to_user(pqi + 1, qi_rsp->Buffer, qi.input_buffer_length)) { 1553 - rc = -EFAULT; 1554 - goto iqinf_exit; 1555 - } 1545 + if (copy_to_user(&pqi->input_buffer_length, 1546 + &qi.input_buffer_length, 1547 + sizeof(qi.input_buffer_length))) 1548 + goto e_fault; 1549 + 1550 + if (copy_to_user(pqi + 1, qi_rsp->Buffer, 1551 + qi.input_buffer_length)) 1552 + goto e_fault; 1556 1553 } 1557 1554 1558 1555 iqinf_exit: ··· 1565 1568 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); 1566 1569 free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base); 1567 1570 return rc; 1571 + 1572 + e_fault: 1573 + rc = -EFAULT; 1574 + goto iqinf_exit; 1568 1575 } 1569 1576 1570 1577 static ssize_t