Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5604946pxb; Mon, 28 Mar 2022 14:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAOSo6Dp+pTajFOOYXz8cdDqHWuKw9mJK86LaJmqNFD8C0unYoie/2A0G7dqvXb4ztLSrP X-Received: by 2002:a17:902:b406:b0:14f:bb35:95ab with SMTP id x6-20020a170902b40600b0014fbb3595abmr27620904plr.140.1648504329269; Mon, 28 Mar 2022 14:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648504329; cv=none; d=google.com; s=arc-20160816; b=ye11n89+QqIW+vOFFgxu+vkqCqe813U8SB+mtYFNgTivK1QVaYYdXlmVIFsjiwCtbZ zv0GcfR3oodIlpYpKo4Ghkk3W4pGwVNociQF/yCXr4KiG1qC9IM67RdjVq8UVSH7IZUb t8inWTPJ9128Oc47fsG0sQrwpBsWTy3olE4cHdcOHRX7AqCUe9IaZN/tnu+2jxoItsJK rlgVql2gjhZML3dpTxj447cyVxIuKODA5rYM7chtHxFm/UaoRlazrXvUo+U840I/Bxmt TouYZNo40rYFInWYCUHLjgCgIzMNVP51Y0Tva3PpMV4+JAA4xgDnGwmYwckWAZ72nxS4 rghQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=KPx/rmNE2IqkPwzgVvOSkXH+L0hTETFepkUJ7cvU4kA=; b=i06H7ihG1wSxfdkyySORtrtQl3VzfenxrIWWcwhbQOqpxFZQknbxCvE4KGkrH6c5nQ /Qj5ZUqx+4AzAJVltXLHhHm+BwKBQzqSSOcM4YhrxTIT7gtz+pHOQQetZGnKmgtecYB9 kcY+9i8tm6GDRogadwRJel+Tii7EUo5Yzdh6ttPVAknPFjyaLs+cLhLD5ckyNFZs71/Y Bfs31rwucgrrMHRhw4lQUyW4wFYAcd2ysReBncQuosLOo3f07mDXj93pvdYmeGmkO+Hi qVl0samt3qtJPmpraF9bwsELobX6gXEvEidbDqPDScC+jBFpfE3fLEH62Lp1GGAH8nck p/wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="eXjmv/dO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pg1-20020a17090b1e0100b001c6454edecasi766746pjb.152.2022.03.28.14.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="eXjmv/dO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29491137F5A; Mon, 28 Mar 2022 14:23:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239109AbiC1IGT (ORCPT + 99 others); Mon, 28 Mar 2022 04:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239116AbiC1IGS (ORCPT ); Mon, 28 Mar 2022 04:06:18 -0400 Received: from m12-17.163.com (m12-17.163.com [220.181.12.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0ACB4532D0; Mon, 28 Mar 2022 01:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=KPx/rmNE2IqkPwzgVv OSkXH+L0hTETFepkUJ7cvU4kA=; b=eXjmv/dOeGRYzXwaV1+6jPIiC1AdmlUzs4 Xrw6XVqy/V6P2zm0D/hVIjfTKxbsh//YpYV2HXJeJM+/XbvWq/QQ0Ikuhd8euAfP rHqrY8xi5w/4SGTOoGvaOhcu96mYlDBmNAhDN7pJRuzabt2kR3TWGfUaJNPIE4Wl 5PLg4t4Kg= Received: from localhost (unknown [159.226.95.33]) by smtp13 (Coremail) with SMTP id EcCowAAnwdIAbEFiPwqmJA--.61675S2; Mon, 28 Mar 2022 16:04:16 +0800 (CST) From: QintaoShen To: tsbogend@alpha.franken.de Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, ralf@linux-mips.org, QintaoShen Subject: [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc() Date: Mon, 28 Mar 2022 16:04:14 +0800 Message-Id: <1648454654-27200-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EcCowAAnwdIAbEFiPwqmJA--.61675S2 X-Coremail-Antispam: 1Uf129KBjvdXoWruFy5KrWDWFW5CrWkuFWUtwb_yoWfZFbE9a yvvF1Dua98Jw17Aw13Xw4rJFy3A347uF4I93Z3tF1SkFyrArZ8WrWkXw15Jry7Wry2vF45 Crs0kF15uw4xKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRE1xR3UUUUU== X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/1tbiNADRH1aD-Qb+DwAAsl X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the memory allocation function kzalloc() may return a NULL pointer, the use of 'gio_dev' may lead to NULL pointer dereference. So it is better to check the return value of kzalloc(). Signed-off-by: QintaoShen --- arch/mips/sgi-ip22/ip22-gio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c index dfc52f6..df7ca21 100644 --- a/arch/mips/sgi-ip22/ip22-gio.c +++ b/arch/mips/sgi-ip22/ip22-gio.c @@ -363,7 +363,11 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq) printk(KERN_INFO "GIO: slot %d : %s (id %x)\n", slotno, name, id); gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL); - gio_dev->name = name; + + if (!gio_dev) + return ; + + gio_dev->name = name; gio_dev->slotno = slotno; gio_dev->id.id = id; gio_dev->resource.start = addr; -- 2.7.4