2013-07-29 08:35:57

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH 1/1] pinctrl: sunxi: Fix incorrect NULL check

*map should be tested for NULL instead of map as kmalloc pointer
is assigned to it. This also fixes a potential null pointer dereference
bug later in the code.

Signed-off-by: Sachin Kamat <[email protected]>
Cc: Maxime Ripard <[email protected]>
---
drivers/pinctrl/pinctrl-sunxi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index c47fd1e..3655a5a 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -175,7 +175,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
}

*map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
- if (!map)
+ if (!*map)
return -ENOMEM;

of_property_for_each_string(node, "allwinner,pins", prop, group) {
--
1.7.9.5


2013-07-29 12:24:15

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH 1/1] pinctrl: sunxi: Fix incorrect NULL check

On Mon, Jul 29, 2013 at 01:49:32PM +0530, Sachin Kamat wrote:
> *map should be tested for NULL instead of map as kmalloc pointer
> is assigned to it. This also fixes a potential null pointer dereference
> bug later in the code.
>
> Signed-off-by: Sachin Kamat <[email protected]>

Acked-by: Maxime Ripard <[email protected]>

Thanks!
Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Attachments:
(No filename) (471.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-08-07 18:21:14

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/1] pinctrl: sunxi: Fix incorrect NULL check

On Mon, Jul 29, 2013 at 10:19 AM, Sachin Kamat <[email protected]> wrote:

> *map should be tested for NULL instead of map as kmalloc pointer
> is assigned to it. This also fixes a potential null pointer dereference
> bug later in the code.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Maxime Ripard <[email protected]>

Patch applied with Maxime's ACK.

Yours,
Linus Walleij