From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758776AbcH3M0f (ORCPT ); Tue, 30 Aug 2016 08:26:35 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:32998 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758458AbcH3M0a (ORCPT ); Tue, 30 Aug 2016 08:26:30 -0400 From: Geliang Tang To: Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck Cc: Geliang Tang , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ramoops: move spin_lock_init after kmalloc error checking Date: Tue, 30 Aug 2016 20:24:42 +0800 Message-Id: <12fb7f17b91d55f53e7aa437e9a25d708a24732c.1472559626.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/pstore/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 7a034d6..ec1c9e5 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -608,12 +608,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); err = pstore_register(&cxt->pstore); if (err) { -- 2.7.4