Skip to content

Commit

Permalink
ramoops: move spin_lock_init after kmalloc error checking
Browse files Browse the repository at this point in the history
If cxt->pstore.buf allocated failed, no need to initialize
cxt->pstore.buf_lock. So this patch moves spin_lock_init() after the
error checking.

Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
geliangtang authored and kees committed Sep 8, 2016
1 parent d771fdf commit f88baf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@ static int ramoops_probe(struct platform_device *pdev)
cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */
cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize);
cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
spin_lock_init(&cxt->pstore.buf_lock);
if (!cxt->pstore.buf) {
pr_err("cannot allocate pstore buffer\n");
err = -ENOMEM;
goto fail_clear;
}
spin_lock_init(&cxt->pstore.buf_lock);

cxt->pstore.flags = PSTORE_FLAGS_DMESG;
if (cxt->console_size)
Expand Down

0 comments on commit f88baf6

Please sign in to comment.