diff mbox

[1/1] video: omapdss: Fix potential null pointer dereference

Message ID 1401445595-22884-1-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Kamat May 30, 2014, 10:26 a.m. UTC
kmalloc can return null. Add a check to avoid potential null
pointer dereference error when the pointer is accessed later.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/video/fbdev/omap2/dss/omapdss-boot-init.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Sachin Kamat June 20, 2014, 9:09 a.m. UTC | #1
On Fri, May 30, 2014 at 3:56 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> kmalloc can return null. Add a check to avoid potential null
> pointer dereference error when the pointer is accessed later.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/video/fbdev/omap2/dss/omapdss-boot-init.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> index 99af9e88b2d8..2f0822ee3ff9 100644
> --- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> +++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> @@ -121,9 +121,11 @@ static void __init omapdss_add_to_list(struct device_node *node, bool root)
>  {
>         struct dss_conv_node *n = kmalloc(sizeof(struct dss_conv_node),
>                 GFP_KERNEL);
> -       n->node = node;
> -       n->root = root;
> -       list_add(&n->list, &dss_conv_list);
> +       if (n) {
> +               n->node = node;
> +               n->root = root;
> +               list_add(&n->list, &dss_conv_list);
> +       }
>  }
>
>  static bool __init omapdss_list_contains(const struct device_node *node)
> --
> 1.7.9.5
>
>

Gentle ping..
Tomi Valkeinen June 23, 2014, 11:43 a.m. UTC | #2
On 30/05/14 13:26, Sachin Kamat wrote:
> kmalloc can return null. Add a check to avoid potential null
> pointer dereference error when the pointer is accessed later.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/video/fbdev/omap2/dss/omapdss-boot-init.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> index 99af9e88b2d8..2f0822ee3ff9 100644
> --- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> +++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
> @@ -121,9 +121,11 @@ static void __init omapdss_add_to_list(struct device_node *node, bool root)
>  {
>  	struct dss_conv_node *n = kmalloc(sizeof(struct dss_conv_node),
>  		GFP_KERNEL);
> -	n->node = node;
> -	n->root = root;
> -	list_add(&n->list, &dss_conv_list);
> +	if (n) {
> +		n->node = node;
> +		n->root = root;
> +		list_add(&n->list, &dss_conv_list);
> +	}
>  }
>  
>  static bool __init omapdss_list_contains(const struct device_node *node)

Thanks, queued for 3.17.

 Tomi
diff mbox

Patch

diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
index 99af9e88b2d8..2f0822ee3ff9 100644
--- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
@@ -121,9 +121,11 @@  static void __init omapdss_add_to_list(struct device_node *node, bool root)
 {
 	struct dss_conv_node *n = kmalloc(sizeof(struct dss_conv_node),
 		GFP_KERNEL);
-	n->node = node;
-	n->root = root;
-	list_add(&n->list, &dss_conv_list);
+	if (n) {
+		n->node = node;
+		n->root = root;
+		list_add(&n->list, &dss_conv_list);
+	}
 }
 
 static bool __init omapdss_list_contains(const struct device_node *node)