Commit 88f370a6 authored by Steve French's avatar Steve French

[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: default avatarSteve French <sfrench@us.ibm.com>
parent 638b2507
...@@ -209,13 +209,15 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, ...@@ -209,13 +209,15 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
i++; i++;
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
length = length = sprintf(buf, "\n%d) %s Uses: %d ", i,
sprintf(buf, tcon->treeName, atomic_read(&tcon->useCount));
"\n%d) %s Uses: %d Type: %s DevInfo: 0x%x " buf += length;
"Attributes: 0x%x\nPathComponentMax: %d Status: %d", if (tcon->nativeFileSystem) {
i, tcon->treeName, length = sprintf("Type: %s ", tcon->nativeFileSystem);
atomic_read(&tcon->useCount), buf += length;
tcon->nativeFileSystem, }
length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x"
"\nPathComponentMax: %d Status: %d",
le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
le32_to_cpu(tcon->fsAttrInfo.Attributes), le32_to_cpu(tcon->fsAttrInfo.Attributes),
le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
......
...@@ -3386,7 +3386,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3386,7 +3386,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
tcon->nativeFileSystem = tcon->nativeFileSystem =
kzalloc(length + 2, GFP_KERNEL); kzalloc(length + 2, GFP_KERNEL);
cifs_strfromUCS_le(tcon->nativeFileSystem, if (tcon->nativeFileSystem)
cifs_strfromUCS_le(
tcon->nativeFileSystem,
(__le16 *) bcc_ptr, (__le16 *) bcc_ptr,
length, nls_codepage); length, nls_codepage);
bcc_ptr += 2 * length; bcc_ptr += 2 * length;
...@@ -3403,6 +3405,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3403,6 +3405,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
tcon->nativeFileSystem = tcon->nativeFileSystem =
kzalloc(length + 1, GFP_KERNEL); kzalloc(length + 1, GFP_KERNEL);
if (tcon->nativeFileSystem)
strncpy(tcon->nativeFileSystem, bcc_ptr, strncpy(tcon->nativeFileSystem, bcc_ptr,
length); length);
} }
......
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