All of lore.kernel.org
 help / color / mirror / Atom feed
From: alex_luca@163.com
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, alex_luca@163.com,
	Zhang Kun <zhangkun@cdjrlc.com>
Subject: [PATCH] pinctrl: renesas:fix possible null pointer dereference struct pinmux_range *
Date: Sun,  7 Feb 2021 23:07:36 +0800	[thread overview]
Message-ID: <20210207150736.24382-1-alex_luca@163.com> (raw)

From: Zhang Kun <zhangkun@cdjrlc.com>

The parameters of  sh_pfc_enum_in_range() pinmux_range *r should be checked
first for possible null ponter, especially when PINMUX_TYPE_FUNCTION as the
pinmux_type was passed by sh_pfc_config_mux().

Signed-off-by: Zhang Kun <zhangkun@cdjrlc.com>
---
 drivers/pinctrl/renesas/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index 2cc457279345..40bbc8366668 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -128,6 +128,9 @@ int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin)
 
 static int sh_pfc_enum_in_range(u16 enum_id, const struct pinmux_range *r)
 {
+	if (!r)
+		return 0;
+
 	if (enum_id < r->begin)
 		return 0;
 
-- 
2.17.1



             reply	other threads:[~2021-02-07 17:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-07 15:07 alex_luca [this message]
2021-02-09 14:12 ` [PATCH] pinctrl: renesas:fix possible null pointer dereference struct pinmux_range * Geert Uytterhoeven
2021-02-09 14:26   ` Alex

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=20210207150736.24382-1-alex_luca@163.com \
    --to=alex_luca@163.com \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=zhangkun@cdjrlc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.