From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B650A2EA731; Mon, 22 Sep 2025 15:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.26 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758555608; cv=none; b=cfHyi+ml0hUcG32aCyLBh0OuQym84tBXkSPzzpYR2dIYd+25lnIKVwh+aJSvRF2+9EibgiON0ODds8y6yzmjEhw3B8pdhJP+NcxPVpfT7r2fJUgz+MR22hqVu0DecdobCpDnCYoT0E0h3H0q0ZA1HZzmjG3c7TX7mwIoMBO0aRs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758555608; c=relaxed/simple; bh=PZ1kMf+7vAyT7H+4UuB5PxqYsoANEJ1LL/IEn5lyBYM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eYBgyy10f+tixnTDRbM7vs62wjIKLRZotWVVmDyjXJrVK2/QvfbYddFQn9WVVnfHxfZiV6qda9rw/zJEc905YUhvqa8Jdx9BeF9ssjRh06w6hzu9v8UEr6rZGrN6FA0t9Ucm9qzMOZ5o1fIs2L6bwX1SiDLBMGVl9s59IHh9g4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=WjH5A3gT; arc=none smtp.client-ip=80.12.242.26 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="WjH5A3gT" Received: from [IPV6:2a01:cb10:785:b00:8347:f260:7456:7662] ([IPv6:2a01:cb10:785:b00:8347:f260:7456:7662]) by smtp.orange.fr with ESMTPA id 0ictvBDlTbkOW0ictvpHmD; Mon, 22 Sep 2025 17:38:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1758555533; bh=V2p0dOk8nY38bVB5z/4E1OBvSqe8R/NqMBDLVbvEpuk=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=WjH5A3gTeEuFhNiV/B2GK5o5zo4aJPBHMJZKCSJn88Z3vjHhHunVXfNgG7ne+JHhj dkWTWzVNM1MtalryFtHg8wJ5Bf7KUg9JyG5pBUjZACfRTLNcjhtbxYLmX1dCURrXDW lGJoQGlN15G80bkx/vwTIjR5kr6SREILz+4jJV0++xF+dmFjE+8ynWpd6DQnVRKQAc T0MGwJxpyrtN1MSS6OC1NCIuJLs2ll5vpYgrNBo9uYTk7vAG11n7cQiWiGNCEl2i03 gfcmed8rR5wu8eDBzhta+pMOub0lNqEfIPoBINJl8BB2q3HR/5XnVWP8gCW6sHGnwx rHRjAoAIALE9Q== X-ME-Helo: [IPV6:2a01:cb10:785:b00:8347:f260:7456:7662] X-ME-Auth: bWFyaW9uLmphaWxsZXRAd2FuYWRvby5mcg== X-ME-Date: Mon, 22 Sep 2025 17:38:53 +0200 X-ME-IP: 2a01:cb10:785:b00:8347:f260:7456:7662 Message-ID: Date: Mon, 22 Sep 2025 17:38:51 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] powerpc/smp: Add check for kcalloc() failure in parse_thread_groups() To: Guangshuo Li , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Thomas Gleixner , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , "Gautham R. Shenoy" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org References: <20250922151025.1821411-1-lgs201920130244@gmail.com> From: Christophe JAILLET Content-Language: en-US, fr-FR In-Reply-To: <20250922151025.1821411-1-lgs201920130244@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 22/09/2025 à 17:10, Guangshuo Li a écrit : > As kcalloc() may fail, check its return value to avoid a NULL pointer > dereference when passing it to of_property_read_u32_array(). > > Fixes: 790a1662d3a26 ("powerpc/smp: Parse ibm,thread-groups with multiple properties") > Cc: stable@vger.kernel.org Signed-off-by that was part of v1, is missing in v2. > --- > changelog: > v2: > - Return -ENOMEM directly on allocation failure. Except for a newline that is removed, v2 is the same as v1, or I miss something? CJ > > Signed-off-by: Guangshuo Li > --- > arch/powerpc/kernel/smp.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 5ac7084eebc0..cfccb9389760 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -822,6 +822,8 @@ static int parse_thread_groups(struct device_node *dn, > > count = of_property_count_u32_elems(dn, "ibm,thread-groups"); > thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL); > + if (!thread_group_array) > + return -ENOMEM; > ret = of_property_read_u32_array(dn, "ibm,thread-groups", > thread_group_array, count); > if (ret)