linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Weiguo Li <liwg06@foxmail.com>
To: andrew@aj.id.au
Cc: joel@jms.id.au, linux-aspeed@lists.ozlabs.org,
	linux-gpio@vger.kernel.org
Subject: [PATCH v2] pinctrl: aspeed: fix null dereference in debug
Date: Wed,  2 Mar 2022 15:12:24 +0800	[thread overview]
Message-ID: <tencent_68563A6FDF372313228831913CC3A7041108@qq.com> (raw)
In-Reply-To: <c51e5a79-168e-4189-ba8e-a426ab82cd89@www.fastmail.com>

"pdesc" is null checked, but already dereferenced ahead in debug.
Swap their positions to avoid potential null dereference.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
---
v2:
* resend it after registering an account in aspeed patchwork
---
 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.25.1


  reply	other threads:[~2022-03-02  7:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01 19:30 [PATCH] pinctrl: aspeed: fix null dereference in debug Weiguo Li
2022-03-02  0:09 ` Andrew Jeffery
2022-03-02  7:12   ` Weiguo Li [this message]
2022-03-03  5:52 ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_68563A6FDF372313228831913CC3A7041108@qq.com \
    --to=liwg06@foxmail.com \
    --cc=andrew@aj.id.au \
    --cc=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).