Skip to content

Commit f88baf6

Browse files
geliangtangkees
authored andcommitted
ramoops: move spin_lock_init after kmalloc error checking
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]>
1 parent d771fdf commit f88baf6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/pstore/ram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,12 @@ static int ramoops_probe(struct platform_device *pdev)
635635
cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */
636636
cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize);
637637
cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
638-
spin_lock_init(&cxt->pstore.buf_lock);
639638
if (!cxt->pstore.buf) {
640639
pr_err("cannot allocate pstore buffer\n");
641640
err = -ENOMEM;
642641
goto fail_clear;
643642
}
643+
spin_lock_init(&cxt->pstore.buf_lock);
644644

645645
cxt->pstore.flags = PSTORE_FLAGS_DMESG;
646646
if (cxt->console_size)

0 commit comments

Comments
 (0)