aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb2file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/smb2file.c')
-rw-r--r--fs/cifs/smb2file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
index 4ed10dd086e6..b204e84b87fb 100644
--- a/fs/cifs/smb2file.c
+++ b/fs/cifs/smb2file.c
@@ -122,12 +122,14 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
122 122
123 /* 123 /*
124 * Accessing maxBuf is racy with cifs_reconnect - need to store value 124 * Accessing maxBuf is racy with cifs_reconnect - need to store value
125 * and check it for zero before using. 125 * and check it before using.
126 */ 126 */
127 max_buf = tcon->ses->server->maxBuf; 127 max_buf = tcon->ses->server->maxBuf;
128 if (!max_buf) 128 if (max_buf < sizeof(struct smb2_lock_element))
129 return -EINVAL; 129 return -EINVAL;
130 130
131 BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
132 max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
131 max_num = max_buf / sizeof(struct smb2_lock_element); 133 max_num = max_buf / sizeof(struct smb2_lock_element);
132 buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL); 134 buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
133 if (!buf) 135 if (!buf)
@@ -264,6 +266,8 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
264 return -EINVAL; 266 return -EINVAL;
265 } 267 }
266 268
269 BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
270 max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
267 max_num = max_buf / sizeof(struct smb2_lock_element); 271 max_num = max_buf / sizeof(struct smb2_lock_element);
268 buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL); 272 buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
269 if (!buf) { 273 if (!buf) {