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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 177AECCA486 for ; Thu, 14 Jul 2022 04:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233814AbiGNEWj (ORCPT ); Thu, 14 Jul 2022 00:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233427AbiGNEWa (ORCPT ); Thu, 14 Jul 2022 00:22:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F430252A8; Wed, 13 Jul 2022 21:22:29 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id BE1BEB82371; Thu, 14 Jul 2022 04:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28190C3411C; Thu, 14 Jul 2022 04:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657772546; bh=I/S6MXKj+pJExOorvIiThOlDOL37GW0RHtgnBej/vcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xak1LbDzW3KzB6ZkyWWdNZqxOvwpxZEXDQUjVyY5087A3iQGVEJAAWOvBgbb6tWtV HOCoANuj7eCiK+ac3/PDc+FSVNHyUcQO70EdkhMjezDBFsO2f4qPa8JeFluIswrdtU N1bYAq2hD4Ze7ch4iSUjMG5fBu/gem/EpRNIypc0vgYYGeuuD8HE5IZVKwG9nVEEFF ia4j7vaORdqiegJQcm5e9g9xaIQgNy/RLMUur5sltIigwQ8BN/Q8OGEVbD7fqSBlYQ 1ojg/t2ZIvsQMBMUmetDN4LZZkDoJggvc0+U64JGmSAlMaDes+RpVrnMFKE7PSYgSz Nu0M3TWUBZsJA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Haowen Bai , Linus Walleij , Sasha Levin , andrew@aj.id.au, joel@jms.id.au, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.18 02/41] pinctrl: aspeed: Fix potential NULL dereference in aspeed_pinmux_set_mux() Date: Thu, 14 Jul 2022 00:21:42 -0400 Message-Id: <20220714042221.281187-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220714042221.281187-1-sashal@kernel.org> References: <20220714042221.281187-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haowen Bai [ Upstream commit 84a85d3fef2e75b1fe9fc2af6f5267122555a1ed ] pdesc could be null but still dereference pdesc->name and it will lead to a null pointer access. So we move a null check before dereference. Signed-off-by: Haowen Bai Link: https://lore.kernel.org/r/1650508019-22554-1-git-send-email-baihaowen@meizu.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/aspeed/pinctrl-aspeed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed.c b/drivers/pinctrl/aspeed/pinctrl-aspeed.c index c94e24aadf92..83d47ff1cea8 100644 --- a/drivers/pinctrl/aspeed/pinctrl-aspeed.c +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed.c @@ -236,11 +236,11 @@ int aspeed_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned int function, const struct aspeed_sig_expr **funcs; const struct aspeed_sig_expr ***prios; - pr_debug("Muxing pin %s for %s\n", pdesc->name, pfunc->name); - if (!pdesc) return -EINVAL; + pr_debug("Muxing pin %s for %s\n", pdesc->name, pfunc->name); + prios = pdesc->prios; if (!prios) -- 2.35.1