Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp692589rbb; Sat, 24 Feb 2024 22:04:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMwYCRJhCY8fXiK7Pitv2NY+BxRh2xGXN+7h2hUQsQ4L/WcmOTaQpl/IQNcdCuhsXoC6DHZqeIRaemadtebl3TTfh4rZDPAHzPgnDNuw== X-Google-Smtp-Source: AGHT+IEO4cqUn186KvoudqTW9+8lfVVJF70xWd62Iaw2JXERF4mV+TjGJF0tBASHn/0N/H0GKywx X-Received: by 2002:a0c:b712:0:b0:68f:5ab1:a135 with SMTP id t18-20020a0cb712000000b0068f5ab1a135mr4110540qvd.47.1708841089265; Sat, 24 Feb 2024 22:04:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708841089; cv=pass; d=google.com; s=arc-20160816; b=rQWfFe+hsxw2cVWu79XFacAKEUfUtxQppBWl8Tl9Dxdbf5pXOyGhcwxYKzB7oV6lMN wG3tt6yhRqizfnF1b0Ch9X28Txgrt6Frr7vLNJJIErIr1jg4MCkbG474RRnR5ghKwYxy ni+h9yDCsc3pjntgnN9292tLbTGSCecSp1aRpQ5YqCF9F7/9IPkDHTuSVp5rwenyKfg2 TP6AzBIMqi/QTT4o76Hmr41XAGLodrXhMYdMkusMk7vFWuifh5UTwJJ5bUDDhgv1b4qr IL75xqzQnPQd+oZJoKXwPtsBLCnl6plkbA6LboNoBEnNWPhmYFVRcKY5KyRT7z5wL2E3 sEaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=y3yU98gncZDf5pi4FSkMKdkFUW11/p3Oj1AXX51gZiE=; fh=G9Sjt63BI5E/YOtwjdxUdqtLe5Ryeb/xOYxbZXPkXa4=; b=jI8nyhFG/y5RiKoFCAUAOyhlmFfOTY0DM0UeXFe2Fl4YO+Q3JnYZG11JvcuUYyTsjD mO5HRoHcI+1crGBu3G3BtKIZIrFe+DbbvVmoMKDEVODEIA3mh42BVl4O0rUNN3gEquTL 4ghLVq4GBWQpc2urRRZJhe7TinKaRp7z1v0vSy/Q9/MR9Yit7NwN8528K6r7ZE38LOPW +g/SARBydmopT+OT3XGmSvzemf2apg1QjQAui3EvY5iBjTP479fWSaTpWrk8SJlinSxy X13G7FDeDo6g9cbQoqCq69lNuovluZ+5sIvZghot6fjLnNVm6fppPqe/iofn1MCHYXYA GI3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-79986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79986-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q7-20020ad45747000000b0068eeeabaa8fsi2602806qvx.144.2024.02.24.22.04.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 22:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-79986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79986-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A5961C20A8C for ; Sun, 25 Feb 2024 06:04:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C427C8C4; Sun, 25 Feb 2024 06:04:44 +0000 (UTC) Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [207.46.229.174]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E852FBE4D for ; Sun, 25 Feb 2024 06:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.46.229.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708841083; cv=none; b=Anh60/+XYwZHIRraRexAIOMp/du2t9yOz/O2KAh5kb6Tw2wS4J9Rd3GQgDF2j4raKsBM1VSNU4jSR69pTDeDnopmXnCuZXIaknry7nogGaSl97PYAZBfrX67u3kpZcMWET8fS7U6bcaHd9IFxbVk3LnZykRvmrPgUwersSpXZJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708841083; c=relaxed/simple; bh=O9pYAacf0RkkUX8+kCmmHElwjDQBmkf/X5szzSGN1hs=; h=From:To:Cc:Subject:Date:Message-Id; b=N3PLdCvlQx9ggcVUa4fnqZTJkRgq2L69pkNWGoWJFIZVzLmUstWl0YVotJAzfcIXxGyOTZfUDogbC1LD7XQ9OY1El/yA6GU77Tq71iDq651NJZvLi7wODyeR+juIzEhmeDq8UoJM2fPpmdNBeSBWhHDPE6X4SCxQyK7+DRAqwOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=207.46.229.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [218.12.16.226]) by mail-app4 (Coremail) with SMTP id cS_KCgC3sH5S2Npl6IGXAQ--.50019S2; Sun, 25 Feb 2024 14:04:10 +0800 (CST) From: Duoming Zhou To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux@armlinux.org.uk, Duoming Zhou Subject: [PATCH] ARM: mvebu: Prevent null pointer dereference caused by kzalloc failure Date: Sun, 25 Feb 2024 14:04:01 +0800 Message-Id: <20240225060401.52768-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:cS_KCgC3sH5S2Npl6IGXAQ--.50019S2 X-Coremail-Antispam: 1UD129KBjvdXoWrtw1fCry8CFW3Zw1xJw17GFg_yoWDGwbEkw s7Aws7u3s3Xwn5Zr13Ca13ur9Iyan8uryxZrn7XF1Fy3yY9Fnrur4vqrZ3Ar43urZFgFWf ArWrur4Yvw1jgjkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb48FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4U MIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbSfO7UUUU U== X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwMBAWXY6VIJRQBCsI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The kzalloc() in i2c_quirk() will return null if the physical memory has run out. As a result, if we dereference the new_compat pointer, the null pointer dereference bug will happen. This patch adds a check to avoid null pointer dereference. Fixes: 5fd62066d290 ("ARM: mvebu: Add thermal quirk for the Armada 375 DB board") Signed-off-by: Duoming Zhou --- arch/arm/mach-mvebu/board-v7.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index fd5d0c8ff69..7d2cb12e349 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -125,6 +125,8 @@ static void __init i2c_quirk(void) struct property *new_compat; new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL); + if (!new_compat) + continue; new_compat->name = kstrdup("compatible", GFP_KERNEL); new_compat->length = sizeof("marvell,mv78230-a0-i2c"); -- 2.17.1