Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3767878pxt; Tue, 10 Aug 2021 10:51:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7cf24glEhTR1icVQwSROBSYNIFrifU3XaxaQ3ImtrUdiZcXKDtj+2/9CYeexa77HSYAWW X-Received: by 2002:a05:6e02:107:: with SMTP id t7mr177345ilm.77.1628617919239; Tue, 10 Aug 2021 10:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617919; cv=none; d=google.com; s=arc-20160816; b=p+BcH6HZrf8hmZq1dK57moFx81XuFHsf7QT9hBaErgqfwI9ktFtAZcBY3wKWeytXzI hZMiuDRaavrStX6dXqqwcUP1+bTHUqiTLJufGL2lV3qcxNhNXrjiW0JHdhANsI+8s7w+ mNRwDSo7YOYzQf+eM3bONTGyVi+CvNJNxzY9UhDhmZ4lSE3NVPtHbM45HszyyjpsfGWl CsbnEU2A2A+zQ4EIrno+yLWihmjb7lImV9tK7HprUUGaca1awOE1zJmw7E1OJX3xr10z rOVYxXH8UlrrmY6qmmhyfisyrWO170jjalzNUIYjBRWvpio6zRagPl+SrcilEeaUzTo8 ldLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RnusLhvc8TZ9cj0aaotfAq1ki/eqhkEr2ORlbIATQ8M=; b=xPZNt/dbGqM78h1uHN9p6ZhAtchwrLhPiDffVlpqKNEyCWAT9nPBHEvih6y4lhSHJk qH75Rb3j9rI2aN1JTq9kJyXwA0EF9JF6tVLj7RhN86CuZoh6ZVJ8im2/a8pdckrQEoOI aOOPTk5gsc31KLGL8wLFsU2MiA4ra/DcY6MW2mnXK7kwOIGDohQ0XyOxCHPYKZPrC5MB XcEDdqcW1lAphlCu84Cq5gVz8BYfJu7wc20YlN/DLqA/blwXAj71fKAzhIhZiw+YeIIz v0Et/QEAZrCkSQt0Qf12cRPgsd4sk6Jbcuc4wjJ5tBSwj5v6elfE7YUtMaNKKSXOWNdc IGfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BI88q0WN; 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 h14si9726334ile.129.2021.08.10.10.51.48; Tue, 10 Aug 2021 10:51:59 -0700 (PDT) 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=BI88q0WN; 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 S235598AbhHJRvZ (ORCPT + 99 others); Tue, 10 Aug 2021 13:51:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:38750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236440AbhHJRsa (ORCPT ); Tue, 10 Aug 2021 13:48:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DCA0F61106; Tue, 10 Aug 2021 17:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617281; bh=/OkUS27hWYMQj6agJae/OvE26auXkIanzdTccsKSKRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BI88q0WNRC7MF0PWKqwEwVbyT6ALAb7fpIYcvZz39qLY/521gCuLBcWSWZh0AEhUL UOaaCihd7yW210lNFgZn/TW1yzgBXxKVHDfQzpzxPQs2GIpmVylGHEZydPil24NdLp /hGv1O842vcMmfVrlug9DGUYQd4GGIstv2PhnqBM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Murphy , Tero Kristo , Kevin Hilman , Tony Lindgren Subject: [PATCH 5.10 108/135] ARM: omap2+: hwmod: fix potential NULL pointer access Date: Tue, 10 Aug 2021 19:30:42 +0200 Message-Id: <20210810172959.435727994@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tero Kristo commit b070f9ca78680486927b799cf6126b128a7c2c1b upstream. omap_hwmod_get_pwrdm() may access a NULL clk_hw pointer in some failure cases. Add a check for the case and bail out gracely if this happens. Reported-by: Dan Murphy Signed-off-by: Tero Kristo Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Kevin Hilman Signed-off-by: Tony Lindgren Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-omap2/omap_hwmod.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -3777,6 +3777,7 @@ struct powerdomain *omap_hwmod_get_pwrdm struct omap_hwmod_ocp_if *oi; struct clockdomain *clkdm; struct clk_hw_omap *clk; + struct clk_hw *hw; if (!oh) return NULL; @@ -3793,7 +3794,14 @@ struct powerdomain *omap_hwmod_get_pwrdm c = oi->_clk; } - clk = to_clk_hw_omap(__clk_get_hw(c)); + hw = __clk_get_hw(c); + if (!hw) + return NULL; + + clk = to_clk_hw_omap(hw); + if (!clk) + return NULL; + clkdm = clk->clkdm; if (!clkdm) return NULL;