浏览代码

video: omapdss: Fix potential null pointer dereference

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>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Sachin Kamat 11 年之前
父节点
当前提交
06f7d79317
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      drivers/video/fbdev/omap2/dss/omapdss-boot-init.c

+ 5 - 3
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)