瀏覽代碼

drm: dereference of tmp in drm_proc_create_files()

tmp allocation may fail, prevent a dereference.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Roel Kluin 16 年之前
父節點
當前提交
1ae70072f0
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      drivers/gpu/drm/drm_proc.c

+ 4 - 0
drivers/gpu/drm/drm_proc.c

@@ -106,6 +106,10 @@ int drm_proc_create_files(struct drm_info_list *files, int count,
 			continue;
 
 		tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
+		if (tmp == NULL) {
+			ret = -1;
+			goto fail;
+		}
 		ent = create_proc_entry(files[i].name, S_IFREG | S_IRUGO, root);
 		if (!ent) {
 			DRM_ERROR("Cannot create /proc/dri/%s/%s\n",