From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753871AbcIHUpM (ORCPT ); Thu, 8 Sep 2016 16:45:12 -0400 Received: from mail-ua0-f182.google.com ([209.85.217.182]:35991 "EHLO mail-ua0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753267AbcIHUpI (ORCPT ); Thu, 8 Sep 2016 16:45:08 -0400 MIME-Version: 1.0 In-Reply-To: <12fb7f17b91d55f53e7aa437e9a25d708a24732c.1472559626.git.geliangtang@gmail.com> References: <12fb7f17b91d55f53e7aa437e9a25d708a24732c.1472559626.git.geliangtang@gmail.com> From: Kees Cook Date: Thu, 8 Sep 2016 13:45:06 -0700 X-Google-Sender-Auth: BugbTU0RYrnE_P6MHlYZc2ttgYs Message-ID: Subject: Re: [PATCH 1/2] ramoops: move spin_lock_init after kmalloc error checking To: Geliang Tang Cc: Anton Vorontsov , Colin Cross , Tony Luck , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 30, 2016 at 5:24 AM, Geliang Tang wrote: > 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); Seems fine to me. No harm either way, but better to save on the work. :) Applied for -next. Thanks! -Kees > > err = pstore_register(&cxt->pstore); > if (err) { > -- > 2.7.4 > -- Kees Cook Nexus Security