]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ramoops: add pdata NULL check to ramoops_probe
authorKees Cook <keescook@chromium.org>
Wed, 16 Nov 2016 00:29:40 +0000 (16:29 -0800)
committerKees Cook <keescook@chromium.org>
Wed, 16 Nov 2016 00:34:32 +0000 (16:34 -0800)
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>
fs/pstore/ram.c

index 380222432efff959a3600cef7ef42a4aa2f6e480..27c059e1760a8918a0dde19cb884c5ff4563606c 100644 (file)
@@ -734,11 +734,20 @@ static int ramoops_probe(struct platform_device *pdev)
                        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.
         */
-       if (cxt->max_dump_cnt)
+       if (cxt->max_dump_cnt) {
+               pr_err("already initialized\n");
                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 &&
                        !pdata->ftrace_size && !pdata->pmsg_size)) {