linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: berlin: Fix to avoid NULL pointer dereference
@ 2019-03-18 23:31 Aditya Pakki
  2019-03-19  5:29 ` Jisheng Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:31 UTC (permalink / raw)
  To: pakki001; +Cc: kjlu, Linus Walleij, Jisheng Zhang, linux-gpio, linux-kernel

of_match_device can return a NULL value when the matching device is
not found. The patch avoids a potential dereference in such scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/pinctrl/berlin/berlin-bg4ct.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pinctrl/berlin/berlin-bg4ct.c b/drivers/pinctrl/berlin/berlin-bg4ct.c
index 6a7fe929a68b..2d5e82938ef9 100644
--- a/drivers/pinctrl/berlin/berlin-bg4ct.c
+++ b/drivers/pinctrl/berlin/berlin-bg4ct.c
@@ -456,6 +456,9 @@ static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *base;
 
+	if (!match)
+		return -ENODEV;
+
 	rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
 	if (!rmconfig)
 		return -ENOMEM;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: berlin: Fix to avoid NULL pointer dereference
  2019-03-18 23:31 [PATCH] pinctrl: berlin: Fix to avoid NULL pointer dereference Aditya Pakki
@ 2019-03-19  5:29 ` Jisheng Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Jisheng Zhang @ 2019-03-19  5:29 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu@umn.edu, Linus Walleij, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Mon, 18 Mar 2019 18:31:29 -0500 Aditya Pakki wrote:
> 
> 
> of_match_device can return a NULL value when the matching device is

This could not happen. If the probe is called, it means OF registered a
device with a valid compatible string, so match cannot be NULL.

> not found. The patch avoids a potential dereference in such scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/pinctrl/berlin/berlin-bg4ct.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pinctrl/berlin/berlin-bg4ct.c b/drivers/pinctrl/berlin/berlin-bg4ct.c
> index 6a7fe929a68b..2d5e82938ef9 100644
> --- a/drivers/pinctrl/berlin/berlin-bg4ct.c
> +++ b/drivers/pinctrl/berlin/berlin-bg4ct.c
> @@ -456,6 +456,9 @@ static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
>         struct resource *res;
>         void __iomem *base;
> 
> +       if (!match)
> +               return -ENODEV;
> +
>         rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
>         if (!rmconfig)
>                 return -ENOMEM;
> --
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-19  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18 23:31 [PATCH] pinctrl: berlin: Fix to avoid NULL pointer dereference Aditya Pakki
2019-03-19  5:29 ` Jisheng Zhang

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).