Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2138346pxb; Fri, 25 Mar 2022 11:46:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ+t/4nWdqmDF6OTvQ+F6yLDLC8hHdQLBMeZV5RoTrKxtvWUB4+Wz+9tGWLKn66LrjMDCV X-Received: by 2002:a05:6a00:16c7:b0:4f7:e497:69c7 with SMTP id l7-20020a056a0016c700b004f7e49769c7mr11014135pfc.7.1648233987456; Fri, 25 Mar 2022 11:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233987; cv=none; d=google.com; s=arc-20160816; b=ygHwNVqfWRBmRgQ0+Zm7XFC9+qT3eaHl78kp4f/g7MynSuTmyIra2+jW/unkiGuYZi frQXAfUCzR/9+5JXRZUjLeNdIfY7ZZx7XF91MQkiEIgQ7dHwYvUqMswjrod2lKZjfK5I SjmntMZevVLhpOWBhhz4TsgDz5BemSDr5it91BUetvx3OfsmhWjtLsUGnbUsj05dYQag 62kKUD7ccmUyOE9m6FndXb3W6Vx5ogSfzgDyELXG8QZuTwXy2TtstYAdfjiA/C8TQIAA l5xqFpl8IfxKqRLrJK9xbykW+7dX6G/NkPGXj+GhJv2dlKn5jJcPKebKhwtjKn/450Pw JPdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:cc:to:from:message-id:dkim-signature; bh=6OcTYymcpn1ETfdJpMGEKngpR17gFGKQz5gHn9I1PVs=; b=NQONZ1WJlfLM6NNOay1MFnrIJdRKlTREf0Sw2UziXOOz26LunjDPg0ehCJlQXSzYYE f9RdDZgX3RrndoSX/upQh4Mud8Cwa+rrL42CEwq7glb3+cUhK2vB8J3gKsT07SZaksbo 2cOMktEwH5/81H3wwRuyFoqUL7WPKbP8ejLRupJgAEcCN+hKz6FwA5p3qJ4N5daTb8yK sXiyVikqfnuD9CWF/+d2ib99NznVXkK4Ug2qaRGnT5HB6QG1o3J32Pp+bOtULTS/nZ8y OlSio0yAGxBcB4rhQO8E/FHoWJXmCIMQ2zZ9r18C9bI42mX6aSIUl8TM+atH0/k4heGe qf+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=OGFF21uW; 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=foxmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b14-20020a056a000cce00b004fa3a8e001asi3839079pfv.209.2022.03.25.11.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:46:27 -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=@foxmail.com header.s=s201512 header.b=OGFF21uW; 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=foxmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C7621BBE0F; Fri, 25 Mar 2022 11:04:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352890AbiCYK7Q (ORCPT + 99 others); Fri, 25 Mar 2022 06:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244096AbiCYK7P (ORCPT ); Fri, 25 Mar 2022 06:59:15 -0400 Received: from out203-205-221-164.mail.qq.com (out203-205-221-164.mail.qq.com [203.205.221.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B81EBD8AF for ; Fri, 25 Mar 2022 03:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1648205855; bh=6OcTYymcpn1ETfdJpMGEKngpR17gFGKQz5gHn9I1PVs=; h=From:To:Cc:Subject:Date; b=OGFF21uWtclTkkMcGS/fvDp5C3/8pZcA3SGyjozfh+OiaeK/UK6uOf06GRSxK6j3S vVCAV/GwAY1p2m3QmYcvsBVUYfjgHdZJYwVZWe9x5enVFLEaNUF/M81k1N3ca0BaHT OXJIqgV0dNL7Fuo2syJwETlZuaVixfyUHedrbxMY= Received: from localhost.localdomain ([43.227.136.188]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id E602687E; Fri, 25 Mar 2022 18:57:32 +0800 X-QQ-mid: xmsmtpt1648205852tconbqa3l Message-ID: X-QQ-XMAILINFO: MR/iVh5QLeieFm7kI9XblVO1Ypif6OeHBEb2nEHDiQJ3sU6oQQmw5b1GkMOP7O Mnb1pv9Urdl+jVwu9BK08Pcl/Qfm274NkG8mQOHFlLL4wJCK/8PRt/Y8ZyqPNW1cPnYLQ5dUVMYI LJNrNT/ETTzZ55PY+baBFGSygMRKPmeqMqwchlkvBsHcOgPvP9aEFB87yzq+hbZGYW7OiwaLibPh rlkxwETKD+Cs8/BdqeGLNzdqNUX4I7lTnqY2dbv129sC8bLaLOFCpsllcBzO4XimrAVS2MWGMPK+ K/aU6U3HErZv+mDnucPhxcus6DecqSMaKZSSGvwfFeZ2OYNiWt/ZD45UiyQHS7SqjuyuJiDzsXuo 7hrtX5IvVcT4wtZgFdB7Hvsl8Fqlgi+jbxQUiItzOMY+tYaeLtVB4IfNUfbdeInrsywTnpN9/Xlu c5hCYDFF2IQNpoHMgq6dhS8n+3tRU33rSIxuEUdTWWOw9C4UBVaBmWkn2MVrehPp6071QN1DpPvW OMXZJCscAPzIl5fUZIuBy/RcMxb63Qn7BSf1OvPI7VkFp4VJGX9GabBMQLkHRBcBbCFrP8tywaay 3qV5yZmg2+sTxXdhJUVGpkrs9CB5UG3gW35WHT3+EmQsuJWhXVO+NbhWXCHvVVnKr5mDZZVqYreH 9qIGtwKjlUThCBHmtMKDTJTab+JY0y1JZOVAsT5oYG1MLedLLdIfQneIHMVFfMyu5UjDwX4Mt/TN c9XjlGHy2eZrJ/jR6rfOs6VaO5M8DFgggsXA7cTVZh5oRwxsvhzP9vWKIr69qMhZ5anmHozWty+3 LJek2SVyH8XvZq1r9MV8aVvIH9o/G7c9DkWJgwTN2A65l/2dsDmPGUtgFJ60MYKGeS37NNuqawyc H3nzDBDKkp346Tvyk4DfVC5erHHN6UDN3jYyNTLGr6w53DHzAd3LDG7If4qbNF9NSzLuahzFjFcB b1rvKqIcE= From: xkernel.wang@foxmail.com To: tsbogend@alpha.franken.de Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] mips: sgi-ip22: add a check for the return of kzalloc() Date: Fri, 25 Mar 2022 18:57:18 +0800 X-OQ-MSGID: <20220325105719.4348-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Xiaoke Wang kzalloc() is a memory allocation function which can return NULL when some internal memory errors happen. So it is better to check it to prevent potential wrong memory access. Signed-off-by: Xiaoke Wang --- arch/mips/sgi-ip22/ip22-gio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c index dfc52f6..38d12f4 100644 --- a/arch/mips/sgi-ip22/ip22-gio.c +++ b/arch/mips/sgi-ip22/ip22-gio.c @@ -363,6 +363,8 @@ 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); + if (!gio_dev) + return; gio_dev->name = name; gio_dev->slotno = slotno; gio_dev->id.id = id; --