Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3890739imw; Mon, 11 Jul 2022 18:57:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIfFrj67zkmRT61kffHK74H0aqTK7qa8joRr8+40mDgO4BVEdlYvKThKvaWryS5kASxWFu X-Received: by 2002:a17:906:a10e:b0:6f3:e70b:b572 with SMTP id t14-20020a170906a10e00b006f3e70bb572mr21974181ejy.546.1657591020095; Mon, 11 Jul 2022 18:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657591020; cv=none; d=google.com; s=arc-20160816; b=XKNpshVNzcGNglwdWaKN/JlfKBZptZhfcfhG624uXeq/Q0Gm56UELgTnYg0UkVSfrf cRCJAiC1XJIhizvbR3WGlRkXYfPa8uHIYNcD9wD8ppqgtsNq0zojpLW5leuc6Emx0X0y VbywSycKPYs5Qs0vzvfDpRI7eGJUlJBSYPGJbxWvPtALrN//2HcFAttRTH1SJ/8ty+pu YeCwuWC+2DN7oliLsOBZ+dhD6XWVlNiOWGuOLRrjcfjF1TVr+SsiG0QQqvevEQTphsnk A4blCEC239Hf27eh2TR8nwf7q299ujrVbUZCC69oI2A9a8M8QNG0l5lmtzrLJ86Wgh2m tG2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dJoHVsOF3Ns0hbojCVbv8KvE/Pi32b6Sl12+Q0qK9b4=; b=DhfMUuP4FsEmETSiBnsV5sr/0KHl4ra2+ceVRLoeHTUE9t/XNI4hcGg2bw8bn2k4cF diNYuCfPAzPHO9i4cxSA5w3xfzm0ccIcdsKbj6OK4kO+6t3ZwY+vA5iCS3/8rjMAptSv UjiVgkSgtXmQmePZ51nJGFaqux4PXePOeHgRvOvJ9V9pUfUQTuVjEmp2C4F8GaeiNdsr FWCDPrl8emZk7d59UA5wUF1q/CyS8/7zdHHVUw81hCAK9uNNx4PSIKgXevgQf57X9XEu 38mnP8bE6ch6Frce3L2zLdbH7Xxsa+7AKtMTntSCME0Cc0bPe3C3zD/TgAOVEZwIdPLC ybUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YVZ7OxEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq36-20020a1709073f2400b00711d9021212si13617524ejc.566.2022.07.11.18.56.35; Mon, 11 Jul 2022 18:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YVZ7OxEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231637AbiGLB1T (ORCPT + 99 others); Mon, 11 Jul 2022 21:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbiGLB1R (ORCPT ); Mon, 11 Jul 2022 21:27:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EFF878B493 for ; Mon, 11 Jul 2022 18:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657589236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dJoHVsOF3Ns0hbojCVbv8KvE/Pi32b6Sl12+Q0qK9b4=; b=YVZ7OxEFLYM0AncmVE9Q1nXpeKg9h1hdcnhQs2csKn+Z26uwRCjUsqUqRCrGOkc5jpEf1o T9vpHBKaJinSKQl0QqKJDzzjxYqQil3eBIVbt0/QzjMMKhBcqTkLlkgyV3ti9lE8Ezo/iX 4Na7ImOxmI36dySM+ZCzJft0HjqoXjg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-20-d6BUpj6FPxK4lPKnQ7Ting-1; Mon, 11 Jul 2022 21:27:14 -0400 X-MC-Unique: d6BUpj6FPxK4lPKnQ7Ting-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F2AF811E81; Tue, 12 Jul 2022 01:27:14 +0000 (UTC) Received: from localhost (ovpn-12-173.pek2.redhat.com [10.72.12.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AF9340D282E; Tue, 12 Jul 2022 01:27:13 +0000 (UTC) Date: Tue, 12 Jul 2022 09:27:09 +0800 From: Baoquan He To: Jianglei Nie Cc: vgoyal@redhat.com, dyoung@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH v4] proc/vmcore: fix potential memory leak in vmcore_init() Message-ID: References: <20220712010055.2328111-1-niejianglei2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220712010055.2328111-1-niejianglei2021@163.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/22 at 09:00am, Jianglei Nie wrote: > elfcorehdr_alloc() allocates a memory chunk for elfcorehdr_addr with > kzalloc(). If is_vmcore_usable() returns false, elfcorehdr_addr is a > predefined value. If parse_crash_elf_headers() occurs some error and ^ s/occurs/gets/ occur is intransitive verb > returns a negetive value, the elfcorehdr_addr should be released with > elfcorehdr_free(). > > fix by calling elfcorehdr_free() when parse_crash_elf_headers() > fails. Fix it by calling elfcorehdr_free() when parse_crash_elf_headers() fails. Other than above log concerns, you can add my ack when repost: Acked-by: Baoquan He Note: - Please also add change history so that people know what's happening during reviewing. For this one, you can skip it. - remember adding all people involved to CC. > > Signed-off-by: Jianglei Nie > --- > fs/proc/vmcore.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c > index 4eaeb645e759..390515c249dd 100644 > --- a/fs/proc/vmcore.c > +++ b/fs/proc/vmcore.c > @@ -1569,15 +1569,16 @@ static int __init vmcore_init(void) > rc = parse_crash_elf_headers(); > if (rc) { > pr_warn("Kdump: vmcore not initialized\n"); > - return rc; > + goto fail; > } > - elfcorehdr_free(elfcorehdr_addr); > elfcorehdr_addr = ELFCORE_ADDR_ERR; > > proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &vmcore_proc_ops); > if (proc_vmcore) > proc_vmcore->size = vmcore_size; > - return 0; > +fail: > + elfcorehdr_free(elfcorehdr_addr); > + return rc; > } > fs_initcall(vmcore_init); > > -- > 2.25.1 >