From: Steve French Date: Wed, 15 Feb 2006 04:30:52 +0000 (-0600) Subject: [PATCH] CIFS: fix cifs_user_read oops when null SMB response on forcedirectio mount X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=93544cc6486bea12e127ed58ca33477bb6ceafe6;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] CIFS: fix cifs_user_read oops when null SMB response on forcedirectio mount This patch fixes an oops reported by Adrian Bunk in cifs_user_read when a null read response is returned on a forcedirectio mount. Signed-off-by: Dave Kleikamp Signed-off-by: Steve French Signed-off-by: Linus Torvalds --- diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d17c97d07c80..675bd2568297 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1442,13 +1442,15 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, &bytes_read, &smb_read_data, &buf_type); pSMBr = (struct smb_com_read_rsp *)smb_read_data; - if (copy_to_user(current_offset, - smb_read_data + 4 /* RFC1001 hdr */ - + le16_to_cpu(pSMBr->DataOffset), - bytes_read)) { - rc = -EFAULT; - } if (smb_read_data) { + if (copy_to_user(current_offset, + smb_read_data + + 4 /* RFC1001 length field */ + + le16_to_cpu(pSMBr->DataOffset), + bytes_read)) { + rc = -EFAULT; + } + if(buf_type == CIFS_SMALL_BUFFER) cifs_small_buf_release(smb_read_data); else if(buf_type == CIFS_LARGE_BUFFER)