From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 724FBC433EF for ; Mon, 24 Jan 2022 16:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tLokoZmy0QiB9VDyUCzVyXoSn6dlm6cx7k5uog4WCJQ=; b=lBiiyyu0Gp439f DQvhjDdzjas/cXhIuC2hw7bxm0JuY6oUXRpk/rYZtW/nRq1nYCyPUD5s802Sr66pq8Dfb24mROBuA qGGTxHXtSClSKt4d53qaYbHxeNZF/eW6DHg5hv+35XRWwURxBBEjnw8Z9FATnchz3f36+Fe/7KZD2 1U0tHTNTqykoFZWl+DvUndWDZE9+xihdTNxP7C1pg3ull8mXOEK6RCRuXju7rYSzVrcl7kx7rUcBK r988WB89fcbTpuqLm/pwL3SLrTue0s79NrfDLtbDtVwDkmvS84odcNBZdou+3FRDHgmncGrQvwVwm h5i8W8SGZRplNfaHwUgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC2Zt-0045Fe-6B; Mon, 24 Jan 2022 16:52:25 +0000 Received: from mta-p5.oit.umn.edu ([134.84.196.205]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC2Zo-0045ET-NV for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 16:52:22 +0000 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id 4JjGHL0PDdz9wjXY for ; Mon, 24 Jan 2022 16:52:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aBAH9fqGgwc2 for ; Mon, 24 Jan 2022 10:52:13 -0600 (CST) Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id 4JjGHK5T7Xz9wjYH for ; Mon, 24 Jan 2022 10:52:13 -0600 (CST) DMARC-Filter: OpenDMARC Filter v1.3.2 mta-p5.oit.umn.edu 4JjGHK5T7Xz9wjYH DKIM-Filter: OpenDKIM Filter v2.11.0 mta-p5.oit.umn.edu 4JjGHK5T7Xz9wjYH Received: by mail-pl1-f198.google.com with SMTP id u14-20020a170902714e00b0014ace69caccso3637843plm.17 for ; Mon, 24 Jan 2022 08:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y+tHqbGxYTZxLAsM/2xshYqCJwWoXL4A34qQepi4q+A=; b=qTRfymmBKC6ulS4TRgxgZKClqn/zZAFzLlGZ9X8q4tPcpU4l6boeMZwpKIVwgfGf0u BUzjWVHswyFWdKCrVRUgyIiUUSdCxNlyQoD40ujFs9DLvHyZ5IA7opMGjYe5NQ32dJ4s jBHYtVUZJ9tooDz2GRD3vJjJ9KXzADNLTsZnWMHV1/uH9g5OquNsWbgWgABBZOfvcIMI efVYuFAs1lQ5EQjCC6JHzf974Lvb+FSKV438Tb5OlBqBm53q1eP38MqODlR1/CsMItMD rk93yz9f+XgCR0cth3LHoR1OsHnZy9nQfUNAJKrIPSj44Y2ihnIQvZAZOLi73L3bI4wh lTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y+tHqbGxYTZxLAsM/2xshYqCJwWoXL4A34qQepi4q+A=; b=wm4yweCnseX+yhiBhqful8NmR/QONxKUODkE7d/Ypp+S9z658f8d/YDGvnTrZG+jhn R2XpepxkxghkTF9XM9MUgxwCikZ5VNqy6Htr31q7XMndoPa0mjjqoYctetxFlrYqrVdo 8G2IqMUljF6KtSh03r95PqM9M2Yn0LVvDcm2UNLI+cLNvVwOoBDXEz2l59PB9SKIehoc lu0Cdfp7uqQFApNWnfn4gHvXPdL+CVnAagEuN7LJ3Neqr6GKRFzwCv6yt+uWiArckAv0 bISQlldtdUWfsJROA7+SmVPAPEOElusM5eE71yGZ5CiHZE9wocrmD14h3dGzZHKLZoX/ Y9fg== X-Gm-Message-State: AOAM531xOrm0wW2T6hyxgvtXNY2GL5OarYJshIpG0Dp2ttzFpc/FGG5j Ft8Wdl38oeV1jzCOs9MLgRQomaeGjZ/jPKj49gTbPNarHKwsJL9hvhQ5Vxa+a++/Ilk3nG0Xb+4 pSK+cuB3KY5MS8ViVm236w6fYE4e69VuJF8bK0R0= X-Received: by 2002:a17:90a:9488:: with SMTP id s8mr2752327pjo.40.1643043132427; Mon, 24 Jan 2022 08:52:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4GMuF2+Hhif3WBk5US0gETu4RE21+7UtomtMNIIf3WFvwybUV3W7ojOWWWG8Hp0/sZjoQAA== X-Received: by 2002:a17:90a:9488:: with SMTP id s8mr2752309pjo.40.1643043132222; Mon, 24 Jan 2022 08:52:12 -0800 (PST) Received: from zqy787-GE5S.lan ([36.4.61.248]) by smtp.gmail.com with ESMTPSA id 17sm16984414pfl.175.2022.01.24.08.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 08:52:11 -0800 (PST) From: Zhou Qingyang To: zhou1615@umn.edu 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: [PATCH] clk: imx: Fix a NULL pointer dereference in imx_register_uart_clocks() Date: Tue, 25 Jan 2022 00:52:06 +0800 Message-Id: <20220124165206.55059-1-zhou1615@umn.edu> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_085220_899624_EB1F0EBF X-CRM114-Status: GOOD ( 14.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel