Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2356631pxb; Sun, 30 Jan 2022 13:26:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ/JDmb5uhrOb8/+ysOyeE3+344+qELlTi6UFnsdvDVHxD3F6TmedqiuaY27417ydtnJtv X-Received: by 2002:a63:2f43:: with SMTP id v64mr14355626pgv.247.1643577998444; Sun, 30 Jan 2022 13:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643577998; cv=none; d=google.com; s=arc-20160816; b=K7FJm1YjlQ7fUNbU3ljwdu+7VOWuxak8y/Jbb04Y7yS2/j2Do/+r5tTJIAHZugddSr uMamqK156JRcIbNqiWowM2iERX2d2gz9L4kFQgaQ2aBfu/6tqEqETAyZ83liy+zL/YaP xI4dE1vqJVFSKfTE1GuR/fwQbqX9OAsmRp9CtiVt/h5AA1EDlyISeroX8hl14+62q9fw vqX+twsPz2URQMrPv6Ti4EwU1TAer+2SzfnP3NPjmruJNL9rGMY9e5JgcYQZGi3hnJHt c3XZNMEhilYqoN3NS27FQj08D4B2KKMMai31Sok0nvYdrzOAteO7SsG7RtgnvmfvdJIZ OEGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9lPT+dZD2JpYk3LpLBX7CXMrtiyC6N35rj6Pgfcihe8=; b=Jvxmm9tR2f0ZaqlvgrdcbtOgKjWOzCd6MRrSbmqXfU7uEBH3tT2vrsQGlYBPI0ZKAv zGq9RS00tG4p2Dfjt/SvStJpCjYpR3PgRrg2mPOkiWzYnrRRYbhRNPTmsP9AmSWNYxUx H9ev8f8bTU9KgC3LI1ITK9uZfE+TcHrQd6+xik4tKgfTgQpb3jd5bj/e1L5XlznRZMbc xAjUwdQwO2KCH8POYc21iC8sIKKzVW6Y69SEthqCnBnpaOboEcNz30Ggubb3PBxyIATI Gh3zlFXiOysLQVOJs0MhZfa5f3zXj1RdlXpjW/eHPU555wYOSAyypEi7zTa+Sypt3YYI tV5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pn5jTamH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k184si5911090pgd.512.2022.01.30.13.26.27; Sun, 30 Jan 2022 13:26:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pn5jTamH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346004AbiA1KQf (ORCPT + 99 others); Fri, 28 Jan 2022 05:16:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343706AbiA1KQY (ORCPT ); Fri, 28 Jan 2022 05:16:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B25C061714; Fri, 28 Jan 2022 02:16:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 553B061E42; Fri, 28 Jan 2022 10:16:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09B43C340E0; Fri, 28 Jan 2022 10:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643364983; bh=AtryLqdfbP2bIln80y7o32pcX0GHQcTsCpCHopwzoaA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pn5jTamHjupkOw2EA3/yJptuMJNs3Xifhj0g2lj1WVKw7S0TdpTWYfvp0YH+lczZM x6SSsd8UBu2y/+mfUslNcEaVzH8J/q80kBqN/DYZTdUJ079em/VeyWwceJmkT69xfm EUQYvt6JMa91tdukdRPuaXflMhYE/tCc18XLamN8= Date: Fri, 28 Jan 2022 11:16:20 +0100 From: Greg KH To: Zhou Qingyang Cc: kjlu@umn.edu, Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Adam Ford , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: imx: Fix a NULL pointer dereference in imx_register_uart_clocks() Message-ID: References: <20220124165206.55059-1-zhou1615@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124165206.55059-1-zhou1615@umn.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 12:52:06AM +0800, Zhou Qingyang wrote: > In imx_register_uart_clocks(), the global variable imx_uart_clocks is > assigned by kcalloc() and there is a dereference of in the next for loop, > which could introduce a NULL pointer dereference on failure of kcalloc(). > > Fix this by adding a NULL check of imx_uart_clocks. > > This bug was found by a static analyzer. > > Builds with 'make allyesconfig' show no new warnings, > and our static analyzer no longer warns about this code. > > Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout") > Signed-off-by: Zhou Qingyang > --- > The analysis employs differential checking to identify inconsistent > security operations (e.g., checks or kfrees) between two code paths > and confirms that the inconsistent operations are not recovered in the > current function or the callers, so they constitute bugs. > > Note that, as a bug found by static analysis, it can be a false > positive or hard to trigger. Multiple researchers have cross-reviewed > the bug. > > drivers/clk/imx/clk.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c > index 7cc669934253..99249ab361d2 100644 > --- a/drivers/clk/imx/clk.c > +++ b/drivers/clk/imx/clk.c > @@ -173,6 +173,8 @@ void imx_register_uart_clocks(unsigned int clk_count) > int i; > > imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); > + if (!imx_uart_clocks) > + return; > > if (!of_stdout) > return; > -- > 2.25.1 > As stated before, umn.edu is still not allowed to contribute to the Linux kernel. Please work with your administration to resolve this issue.