From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pv50p00im-ztdg10012001.me.com (pv50p00im-ztdg10012001.me.com [17.58.6.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B532192B60 for ; Sat, 11 Jan 2025 12:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736599973; cv=none; b=sQzeDURYleHB22Tok+gy3mNR79qLQRB/bQmJXjqyNrSZTqvDyP7PQTlQpItx5jtNE5PrQPUkMI2Fi2jnU5nqZIDmgDGMTUk9wDi3e/QLwsC6gS3HIt8y4/2WpbtoyNvM1SPeoQd24Ue3ZmWH5P4rYCZILacssBaNrRzaBsRu0xQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736599973; c=relaxed/simple; bh=CG7wOT9feGtbJytF5bO/h6edaWj/RbG31qKSWxqnBAg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eg72QKoZtO+XdIORlArpMpV1vfCn1XWAhC5cVbLnrX2grZClhGY/vbtblQbGdNkfCbp7I6Fc0Jr9y0M4c9x18917QQmXquKLvdWx44o2blUx9g9s++R7cx0aRz1b1tDY+uKToY4y8Tzxivhe2Vp5L1HlSMUwnenkeV9X9MKGdlA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=HcezXZny; arc=none smtp.client-ip=17.58.6.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="HcezXZny" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736599970; bh=LMpX2Ad36CGz6ptWggqRWYsj20HCMu4L/jmLJQ3uV/c=; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type: x-icloud-hme; b=HcezXZnyCj6xuHh9YxczAVkqexdlWdfsNC07F6VvBXOBQfaVQWvFzDH1gqTwGzBAz cDG1RZ763WSdotdBf9aZhlq/eo+g6ieBKcy1TLbrfucnIipmb1eV3Crk4b3p22kEv7 lKX9JRUhgI57+zRVXo6ghNt+Y/PdNiJWWP0OZIdHl3ZhuZSEHlnZjSd6BlNecv4stB vsIKEbIZre0JKjX4nN/Z3AePGW2tjFVPSBFTJXAGr8AhphlPx5fj0ZYUqKqU+Nt8Hj Z3DU26yzGuHi5tD8vSzHxFZV+YnpkD9k37kvOZsG5vhAD0eEIF9QAaFQKf9cPzw7Bl cbH91tRFC8XoQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10012001.me.com (Postfix) with ESMTPSA id 30784A0366; Sat, 11 Jan 2025 12:52:43 +0000 (UTC) Message-ID: <7ac7b17a-0cfa-44a9-bfe7-35792609e248@icloud.com> Date: Sat, 11 Jan 2025 20:52:39 +0800 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 v4 06/14] of: property: Avoiding using uninitialized variable @imaplen in parse_interrupt_map() To: Krzysztof Kozlowski Cc: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> <20250109-of_core_fix-v4-6-db8a72415b8c@quicinc.com> <20250110202649.GA3227291-robh@kernel.org> Content-Language: en-US From: Zijun Hu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: lc2EQkYlwLtMiKbKtOsuzw2TRLEqvi4i X-Proofpoint-ORIG-GUID: lc2EQkYlwLtMiKbKtOsuzw2TRLEqvi4i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-11_05,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501110111 On 2025/1/11 17:01, Krzysztof Kozlowski wrote: > On Sat, Jan 11, 2025 at 06:34:21AM +0800, Zijun Hu wrote: >> On 2025/1/11 04:26, Rob Herring wrote: >>> On Thu, Jan 09, 2025 at 09:26:57PM +0800, Zijun Hu wrote: >>>> From: Zijun Hu >>>> >>>> parse_interrupt_map() will use uninitialized variable @imaplen if fails >>>> to get property 'interrupt-map'. >>>> >>>> Fix by using the variable after successfully getting the property. >>>> >>>> Fixes: e7985f43609c ("of: property: Fix fw_devlink handling of interrupt-map") >>>> Signed-off-by: Zijun Hu >>>> --- >>>> drivers/of/property.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/of/property.c b/drivers/of/property.c >>>> index dca1a3ebccae1093b2b11f51e8e692bca854d0e3..6245cbff3527d762c16e7f4b7b7b3d4f2e9ddbe6 100644 >>>> --- a/drivers/of/property.c >>>> +++ b/drivers/of/property.c >>>> @@ -1391,9 +1391,9 @@ static struct device_node *parse_interrupt_map(struct device_node *np, >>>> addrcells = of_bus_n_addr_cells(np); >>>> >>>> imap = of_get_property(np, "interrupt-map", &imaplen); >>>> - imaplen /= sizeof(*imap); >>>> if (!imap) >>>> return NULL; >>>> + imaplen /= sizeof(*imap); >>> >>> sizeof() is a compile time constant, there's not an actual dereference >>> here. >>> >> >> the uninitialized variable is @imaplen, and not sizeof(*imap). > > Correct. I think error is harmless, because whatever stack/random value > of imaplen we use in 'imaplen / =sizeof', we immediately return. > > Anyway, for code correctness and silencing whatever warnings there are > (if there are you should actually paste them in commit msg): > thank you Krzysztof Kozlowski for code review. no warning messages since this issue is found by reading code. > Reviewed-by: Krzysztof Kozlowski > > Best regards, > Krzysztof >