Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp591060pxb; Tue, 29 Mar 2022 08:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA4C003ERhmNO0La1SA4bdJDeR9RAgCdv6c3I+08RyvyhRc/fgFt5NdfzrIPGvoMU24DuZ X-Received: by 2002:a17:902:dccd:b0:156:c33:8839 with SMTP id t13-20020a170902dccd00b001560c338839mr10596804pll.145.1648566560128; Tue, 29 Mar 2022 08:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648566560; cv=none; d=google.com; s=arc-20160816; b=TUpVhC60e9dV04dmXZTR3+NeKQuH3PBkBT83o/A6MWH0N7FXYEMGC4W9u6IaqtMmOO /APABzRPfKJJsyZOtcPc026vEXnsA3q8v8m4O3N7/11uRrWFAzp/u+dOAtCGKf+9BxN/ tyDAc5GBfQrfrJzTVeOPCHnk5o7myUGMKeRu1+6VpNoLAq/B/xSuUDVVKMNg45axZTN7 CCKriUdFvVkrCSmxEhgAtZInMVi96IJcDUeTIafejQX0uGnqwNbAyRh/FgDgZIsCC6D1 eYEr57p20TSAG3MHUUQxSHo9mhGru20g3/FkR3kjCI+8sRnioXnW0jyeUN6n3bEK04De amjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-filter; bh=JdGMhVZb2mORi2Bv46bPFngcErgTo+sVnMYvkiK8TME=; b=Z2xd26BvfcfNb/jX8SLkdW88xdBJtD1AjZCWYJxhfVJm7uBbgw+KEWepfmYyj//m+d C3btPEzqDIQXz/RFEYCQGCQqxQ/q3zUrcNSqF1fVbparoy52bSu+XfeW+ZC53GIyEs9z MS4n04RnD6wAh1w/PWEyQCs7S9V+1k3Jsnpi/qrpLoz8n0fiCo86Oo9mjawxS3vVjt3W j4mQwBf2UCkeIDkkho7imX4TT4nqBjS6ydqX4U+AS/MQc0oTg+uSwRwHJBnhG2+AS1tt JlAY45EjklxU36r8IPN51xjVZQRxdIfTG+ZH8WrlVwJnSpiASivRZcjFi6cEyRBnU838 UrMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a63a512000000b003816043ee4csi17544132pgf.65.2022.03.29.08.09.01; Tue, 29 Mar 2022 08:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234043AbiC2Igw (ORCPT + 99 others); Tue, 29 Mar 2022 04:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbiC2Igv (ORCPT ); Tue, 29 Mar 2022 04:36:51 -0400 Received: from mxout02.lancloud.ru (mxout02.lancloud.ru [45.84.86.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA4823DE8F; Tue, 29 Mar 2022 01:35:05 -0700 (PDT) Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout02.lancloud.ru BED922208DDD Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc() To: QintaoShen , CC: , , References: <1648454654-27200-1-git-send-email-unSimple1993@163.com> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <6dd8bcf0-20a1-0bab-b48e-ec1bac5c15f0@omp.ru> Date: Tue, 29 Mar 2022 11:35:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1648454654-27200-1-git-send-email-unSimple1993@163.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 Hello! On 3/28/22 11:04 AM, QintaoShen wrote: > 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) Indented too little. And indent with tabs please, not spaces. > + return ; No need for space before ';'. [...] MBR, Sergey