From patchwork Wed Aug 20 10:39:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 4748931 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67BF2C0338 for ; Wed, 20 Aug 2014 10:40:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0275A20155 for ; Wed, 20 Aug 2014 10:40:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DFA820176 for ; Wed, 20 Aug 2014 10:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbaHTKjb (ORCPT ); Wed, 20 Aug 2014 06:39:31 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:15153 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752288AbaHTKj3 (ORCPT ); Wed, 20 Aug 2014 06:39:29 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAL007Z5PLS9PD0@mailout1.samsung.com> for linux-cifs@vger.kernel.org; Wed, 20 Aug 2014 19:39:28 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.116]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 7E.71.15745.0EA74F35; Wed, 20 Aug 2014 19:39:28 +0900 (KST) X-AuditID: cbfee691-b7f306d000003d81-ed-53f47ae05b83 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 50.15.04943.0EA74F35; Wed, 20 Aug 2014 19:39:28 +0900 (KST) Received: from DONAMJAEJEO06 ([10.88.104.63]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NAL0021WPLSZJ00@mmp1.samsung.com>; Wed, 20 Aug 2014 19:39:28 +0900 (KST) From: Namjae Jeon To: 'Steve French' Cc: 'Shirish Pargaonkar' , 'Pavel Shilovsky' , linux-cifs@vger.kernel.org, Ashish Sangwan Subject: [PATCH 4/7] cifs: fix a possible null pointer deref in decode_ascii_ssetup Date: Wed, 20 Aug 2014 19:39:28 +0900 Message-id: <003701cfbc63$04fdf490$0ef9ddb0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac+8YriXsWOnwjJ6R+uVaK1XCI9KFg== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsWyRsSkRPdB1Zdgg4Nn5SyWTrzEbPHi/y5m i3N7WS1ezGlgtHjz4jCbA6vHzll32T3m7upj9OjbsorR4/MmuQCWKC6blNSczLLUIn27BK6M 14tesxa8ZKtobd7A0sB4jLWLkZNDQsBE4sPrm2wQtpjEhXvrgWwuDiGBpYwSLWfmsMMUvXnR wQiRWMQosXjlRRYI5y+jxPHdIKM4ONgEtCX+bBEFaRARUJf4vPwvM4jNLLCCUeLRLxMQW1gg VGLns69gQ1kEVCWWzeoCu4JXwFLiR9NsRghbUOLH5HssEL1aEut3HmeCsOUlNq95ywxxkILE jrOvGSF26UkcenkOql5EYt+Ld2CHSghsY5eYf2wZ1DIBiW+TD7GA3CkhICux6QDUHEmJgytu sExgFJuFZPUsJKtnIVk9C8mKBYwsqxhFUwuSC4qT0otM9YoTc4tL89L1kvNzNzEC4+30v2cT dzDeP2B9iDEZaP1EZinR5HxgvOaVxBsamxlZmJq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Mgvfos165JvSB/1lD17d5ljMnrrO46vX1+1BwUtYd7/JSZCfp5XzVEfhld5np5Yv/AFK LMUZiYZazEXFiQCyVqXv/AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When kzalloc fails, we will end up doing NULL pointer derefrence Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan --- fs/cifs/sess.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 39b8507..07fe97a 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -243,10 +243,11 @@ static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft, kfree(ses->serverOS); ses->serverOS = kzalloc(len + 1, GFP_KERNEL); - if (ses->serverOS) + if (ses->serverOS) { strncpy(ses->serverOS, bcc_ptr, len); - if (strncmp(ses->serverOS, "OS/2", 4) == 0) - cifs_dbg(FYI, "OS/2 server\n"); + if (strncmp(ses->serverOS, "OS/2", 4) == 0) + cifs_dbg(FYI, "OS/2 server\n"); + } bcc_ptr += len + 1; bleft -= len + 1;