Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=88f370a688e765de9755a343702ca04e6817e5f5
Commit:     88f370a688e765de9755a343702ca04e6817e5f5
Parent:     638b250766272fcaaa0f7ed2776f58f4ac701914
Author:     Steve French <[EMAIL PROTECTED]>
AuthorDate: Sat Sep 15 03:01:17 2007 +0000
Committer:  Steve French <[EMAIL PROTECTED]>
CommitDate: Sat Sep 15 03:01:17 2007 +0000

    [CIFS] Fix potential NULL pointer usage if kzalloc fails
    
    Potential problem was noticed by Cyrill Gorcunov
    
    CC: Cyrill Gorcunov <[EMAIL PROTECTED]>
    Signed-off-by: Steve French <[EMAIL PROTECTED]>
---
 fs/cifs/cifs_debug.c |   16 +++++++++-------
 fs/cifs/connect.c    |   13 ++++++++-----
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 1bf8cf5..0356694 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,
                i++;
                tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
                dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
-               length =
-                   sprintf(buf,
-                           "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x "
-                           "Attributes: 0x%x\nPathComponentMax: %d Status: %d",
-                           i, tcon->treeName,
-                           atomic_read(&tcon->useCount),
-                           tcon->nativeFileSystem,
+               length = sprintf(buf, "\n%d) %s Uses: %d ", i,
+                                tcon->treeName, atomic_read(&tcon->useCount));
+               buf += length;
+               if (tcon->nativeFileSystem) {
+                       length = sprintf("Type: %s ", tcon->nativeFileSystem);
+                       buf += length;
+               }
+               length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x"
+                                "\nPathComponentMax: %d Status: %d",
                            le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
                            le32_to_cpu(tcon->fsAttrInfo.Attributes),
                            
le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index a83684d..5f2ec19 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3386,9 +3386,11 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
                                kfree(tcon->nativeFileSystem);
                                tcon->nativeFileSystem =
                                    kzalloc(length + 2, GFP_KERNEL);
-                               cifs_strfromUCS_le(tcon->nativeFileSystem,
-                                                  (__le16 *) bcc_ptr,
-                                                  length, nls_codepage);
+                               if (tcon->nativeFileSystem)
+                                       cifs_strfromUCS_le(
+                                               tcon->nativeFileSystem,
+                                               (__le16 *) bcc_ptr,
+                                               length, nls_codepage);
                                bcc_ptr += 2 * length;
                                bcc_ptr[0] = 0; /* null terminate the string */
                                bcc_ptr[1] = 0;
@@ -3403,8 +3405,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
                                kfree(tcon->nativeFileSystem);
                                tcon->nativeFileSystem =
                                    kzalloc(length + 1, GFP_KERNEL);
-                               strncpy(tcon->nativeFileSystem, bcc_ptr,
-                                       length);
+                               if (tcon->nativeFileSystem)
+                                       strncpy(tcon->nativeFileSystem, bcc_ptr,
+                                               length);
                        }
                        /* else do not bother copying these information fields*/
                }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to