Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 446

kernel-2.6.18-238.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Thu, 19 Nov 2009 14:38:33 -0500
Subject: [cifs] fix potential NULL deref in parse_DFS_referrals
Message-id: <1258641517-20756-7-git-send-email-jlayton@redhat.com>
Patchwork-id: 21438
O-Subject: [RHEL5.5 PATCH 06/10] BZ#500838: cifs: potential NULL dereference in
	parse_DFS_referrals()
Bugzilla: 500838
RH-Acked-by: Peter Staubach <staubach@redhat.com>

From: Steve French <sfrench@us.ibm.com>

(Upstream commit 2920ee2b47fc8e6aebe1d1956b2725f48fa93cc5)

memory allocation may fail, prevent a NULL dereference

Pointed out by Roel Kluin

CC: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index e3351ac..f112010 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -3969,6 +3969,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
 		if (is_unicode) {
 			__le16 *tmp = kmalloc(strlen(searchName)*2 + 2,
 						GFP_KERNEL);
+			if (tmp == NULL) {
+				rc = -ENOMEM;
+				goto parse_DFS_referrals_exit;
+			}
 			cifsConvertToUCS((__le16 *) tmp, searchName,
 					PATH_MAX, nls_codepage, remap);
 			node->path_consumed = cifs_ucs2_bytes(tmp,