浏览代码

ramoops: add pdata NULL check to ramoops_probe

This adds a check for a NULL platform data, which should only be possible
if a driver incorrectly sets up a probe request without also having defined
the platform_data structure. This is based on a patch from Geliang Tang.

Signed-off-by: Kees Cook <keescook@chromium.org>
Kees Cook 8 年之前
父节点
当前提交
fc46d4e453
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      fs/pstore/ram.c

+ 11 - 2
fs/pstore/ram.c

@@ -734,11 +734,20 @@ static int ramoops_probe(struct platform_device *pdev)
 			goto fail_out;
 			goto fail_out;
 	}
 	}
 
 
-	/* Only a single ramoops area allowed at a time, so fail extra
+	/*
+	 * Only a single ramoops area allowed at a time, so fail extra
 	 * probes.
 	 * probes.
 	 */
 	 */
-	if (cxt->max_dump_cnt)
+	if (cxt->max_dump_cnt) {
+		pr_err("already initialized\n");
 		goto fail_out;
 		goto fail_out;
+	}
+
+	/* Make sure we didn't get bogus platform data pointer. */
+	if (!pdata) {
+		pr_err("NULL platform data\n");
+		goto fail_out;
+	}
 
 
 	if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size &&
 	if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size &&
 			!pdata->ftrace_size && !pdata->pmsg_size)) {
 			!pdata->ftrace_size && !pdata->pmsg_size)) {