aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-09-14 23:01:17 -0400
committerSteve French <sfrench@us.ibm.com>2007-09-14 23:01:17 -0400
commit88f370a688e765de9755a343702ca04e6817e5f5 (patch)
tree82ad179c2310cf60c8aa83c50e221f363b51d8fe /fs
parent638b250766272fcaaa0f7ed2776f58f4ac701914 (diff)
[CIFS] Fix potential NULL pointer usage if kzalloc fails
Potential problem was noticed by Cyrill Gorcunov CC: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifs_debug.c16
-rw-r--r--fs/cifs/connect.c13
2 files changed, 17 insertions, 12 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 1bf8cf522ad6..0356694b5cd0 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -209,13 +209,15 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
209 i++; 209 i++;
210 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 210 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
211 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 211 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
212 length = 212 length = sprintf(buf, "\n%d) %s Uses: %d ", i,
213 sprintf(buf, 213 tcon->treeName, atomic_read(&tcon->useCount));
214 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x " 214 buf += length;
215 "Attributes: 0x%x\nPathComponentMax: %d Status: %d", 215 if (tcon->nativeFileSystem) {
216 i, tcon->treeName, 216 length = sprintf("Type: %s ", tcon->nativeFileSystem);
217 atomic_read(&tcon->useCount), 217 buf += length;
218 tcon->nativeFileSystem, 218 }
219 length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x"
220 "\nPathComponentMax: %d Status: %d",
219 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), 221 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
220 le32_to_cpu(tcon->fsAttrInfo.Attributes), 222 le32_to_cpu(tcon->fsAttrInfo.Attributes),
221 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), 223 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index a83684d8eb5a..5f2ec1946776 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3386,9 +3386,11 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3386 kfree(tcon->nativeFileSystem); 3386 kfree(tcon->nativeFileSystem);
3387 tcon->nativeFileSystem = 3387 tcon->nativeFileSystem =
3388 kzalloc(length + 2, GFP_KERNEL); 3388 kzalloc(length + 2, GFP_KERNEL);
3389 cifs_strfromUCS_le(tcon->nativeFileSystem, 3389 if (tcon->nativeFileSystem)
3390 (__le16 *) bcc_ptr, 3390 cifs_strfromUCS_le(
3391 length, nls_codepage); 3391 tcon->nativeFileSystem,
3392 (__le16 *) bcc_ptr,
3393 length, nls_codepage);
3392 bcc_ptr += 2 * length; 3394 bcc_ptr += 2 * length;
3393 bcc_ptr[0] = 0; /* null terminate the string */ 3395 bcc_ptr[0] = 0; /* null terminate the string */
3394 bcc_ptr[1] = 0; 3396 bcc_ptr[1] = 0;
@@ -3403,8 +3405,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3403 kfree(tcon->nativeFileSystem); 3405 kfree(tcon->nativeFileSystem);
3404 tcon->nativeFileSystem = 3406 tcon->nativeFileSystem =
3405 kzalloc(length + 1, GFP_KERNEL); 3407 kzalloc(length + 1, GFP_KERNEL);
3406 strncpy(tcon->nativeFileSystem, bcc_ptr, 3408 if (tcon->nativeFileSystem)
3407 length); 3409 strncpy(tcon->nativeFileSystem, bcc_ptr,
3410 length);
3408 } 3411 }
3409 /* else do not bother copying these information fields*/ 3412 /* else do not bother copying these information fields*/
3410 } 3413 }