From patchwork Tue Dec 18 14:35:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 10735767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3A141399 for ; Tue, 18 Dec 2018 14:36:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E37EC2968B for ; Tue, 18 Dec 2018 14:36:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D703229C08; Tue, 18 Dec 2018 14:36:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D27B2968B for ; Tue, 18 Dec 2018 14:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbeLROg1 (ORCPT ); Tue, 18 Dec 2018 09:36:27 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:48963 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbeLROg1 (ORCPT ); Tue, 18 Dec 2018 09:36:27 -0500 Received: from localhost.localdomain ([109.104.51.109]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MwgKC-1hKFGj0638-00y6oJ; Tue, 18 Dec 2018 15:36:19 +0100 From: Michael Heimpold To: linux-mmc@vger.kernel.org, chris@printf.net Cc: Michael Heimpold , Michael Heimpold Subject: [PATCH mmc-utils 1/5] Check calloc's return value before using the pointer Date: Tue, 18 Dec 2018 15:35:57 +0100 Message-Id: <20181218143601.24413-2-michael.heimpold@i2se.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181218143601.24413-1-michael.heimpold@i2se.com> References: <20181218143601.24413-1-michael.heimpold@i2se.com> X-Provags-ID: V03:K1:/brD5AX3H1GeoDmaeFmrpdalfGeMJMC7X9C1BYNjkixwY05TjpI dLBin1/imsifYO3X23FOH9FjlfKbkf1ffeqhnilFdFbLrMlBthn0Y4fEHHkFeHtgWlqIO3Y CRBqIcfZf/HhR3rNqf9LcCfrndTDLU7rf2drRMxh6xbNi5/bp1uqtUtrgLRNaGO/wjBslRL GZTB7P9JDxq5GcT3Fe7zQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:m13+BF637NE=:5oFpBnw5jRPKMysrU2HXlR +rSuMwQuTS3ODL3zBwad3+IsQKB8+NuwJW907no/mkBVl5ATL0FmH1Du7ec+TYkE6L2M/vvXK Tbo1s/K2KFEzoEa8grPPYyJlhLUW53IPVjtCZdD7oPwKjPlcrtjL92IlRRZf4i0jqrsbiy1Qx cHV3eUF5uOIJQ870fYjN4ETvtXTG2Cwq3IcVmfpp6pMUgFw3ekxvnkylHMNDGKqOAaRpkegxk cpTXhrpXs5SO9vHR5XJud930ry8p7fl63UPoSQ39IWqhyTFPrZzgftViGSqhdXAVqYvGdWkc5 XTUyxT368rgCypNMtEGKJxhkXsbo3Xtc1fDXdkagPi78oGs2rGAlH2qUpO2Ee+/805lB4HbnX tAOqTUISL7/eORcWNvz2UfVHEltoNlB3UE0nHFly3YjFdjbDHB7unQYwdoSJ5fcQ3O1xJDDA0 K5XfJanoSYmt2bHPueWSHfer3R4ARzIL4oP9s+3Bspar3Ld1ju6/kR/yEmOAhs9O3HvTpgJTP OsJvFEQzjF8Zm7mc2HbGKbuPDoGL4qO2vokdLvyp4r+c1RtGegawcfxoBZMPeQ5KLinR1MPuv 5Nrj+ff6xnmMZnYa7yd2a2t+xKZyjih2MI4y58bpDSiMJsdne/+1kJaQ7s08Zo9dSwpF3LSA6 femk2KTGv78jj9TGVYSifsqX8hJ43ABDuhjOUx1hPxmZJEQoa0PTJcmxZOEAZLLb9liKEdiWP esfDo08zOQMd5Il1F5FXKYqzDFJ0etLUji3aYX4Eqm720VUKdWR9mCVfwkI= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If calloc fails, bail out immediately instead of trying to use the NULL pointer. Signed-off-by: Michael Heimpold Cc: Michael Heimpold --- lsmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lsmmc.c b/lsmmc.c index 9737b37..e514c83 100644 --- a/lsmmc.c +++ b/lsmmc.c @@ -374,6 +374,8 @@ char *to_binstr(char *hexstr) char *binstr; binstr = calloc(strlen(hexstr) * 4 + 1, sizeof(char)); + if (!binstr) + return NULL; while (hexstr && *hexstr != '\0') { if (!isxdigit(*hexstr))