提交 f88baf68 编写于 作者: G Geliang Tang 提交者: Kees Cook

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: NGeliang Tang <geliangtang@gmail.com>
Signed-off-by: NKees Cook <keescook@chromium.org>
上级 d771fdf9
...@@ -635,12 +635,12 @@ static int ramoops_probe(struct platform_device *pdev) ...@@ -635,12 +635,12 @@ static int ramoops_probe(struct platform_device *pdev)
cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */ cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */
cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize); cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize);
cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL); cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
spin_lock_init(&cxt->pstore.buf_lock);
if (!cxt->pstore.buf) { if (!cxt->pstore.buf) {
pr_err("cannot allocate pstore buffer\n"); pr_err("cannot allocate pstore buffer\n");
err = -ENOMEM; err = -ENOMEM;
goto fail_clear; goto fail_clear;
} }
spin_lock_init(&cxt->pstore.buf_lock);
cxt->pstore.flags = PSTORE_FLAGS_DMESG; cxt->pstore.flags = PSTORE_FLAGS_DMESG;
if (cxt->console_size) if (cxt->console_size)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册