* [PATCH] pinctrl: berlin: as370: Fix to avoid NULL pointer dereference
@ 2019-03-18 23:37 Aditya Pakki
2019-03-19 5:30 ` Jisheng Zhang
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:37 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, Linus Walleij, Jisheng Zhang, linux-gpio, linux-kernel
of_match_device in as370_pinctrl_probe 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/pinctrl-as370.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pinctrl/berlin/pinctrl-as370.c b/drivers/pinctrl/berlin/pinctrl-as370.c
index 44f8ccdbeeff..78bb5b866c99 100644
--- a/drivers/pinctrl/berlin/pinctrl-as370.c
+++ b/drivers/pinctrl/berlin/pinctrl-as370.c
@@ -337,6 +337,8 @@ static int as370_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: as370: Fix to avoid NULL pointer dereference
2019-03-18 23:37 [PATCH] pinctrl: berlin: as370: Fix to avoid NULL pointer dereference Aditya Pakki
@ 2019-03-19 5:30 ` Jisheng Zhang
0 siblings, 0 replies; 2+ messages in thread
From: Jisheng Zhang @ 2019-03-19 5:30 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:37:27 -0500 Aditya Pakki wrote:
>
>
> of_match_device in as370_pinctrl_probe can return a NULL value
> when the matching device is not found. The patch avoids a potential
Similar as the comment to your previous patch, 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.
> dereference in such scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> drivers/pinctrl/berlin/pinctrl-as370.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pinctrl/berlin/pinctrl-as370.c b/drivers/pinctrl/berlin/pinctrl-as370.c
> index 44f8ccdbeeff..78bb5b866c99 100644
> --- a/drivers/pinctrl/berlin/pinctrl-as370.c
> +++ b/drivers/pinctrl/berlin/pinctrl-as370.c
> @@ -337,6 +337,8 @@ static int as370_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:30 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:37 [PATCH] pinctrl: berlin: as370: Fix to avoid NULL pointer dereference Aditya Pakki
2019-03-19 5:30 ` 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).