Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3868475imw; Mon, 11 Jul 2022 18:17:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s7jjtyM/VlxEmOIhLfPXyH0ckpvJda/cJlXqRJAFuYJRZVNKnfedwzvL4FbG1/Dw7YVlxZ X-Received: by 2002:a17:907:7242:b0:726:f510:4bfa with SMTP id ds2-20020a170907724200b00726f5104bfamr21048539ejc.219.1657588635128; Mon, 11 Jul 2022 18:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657588635; cv=none; d=google.com; s=arc-20160816; b=O8z5VQp2c7bEXXfjdocTb2GY9TTUGcAntgVtoUceqK+OFDiafdH0umdiEGdEca5n4W rtwxeuAjUDa7mVzALDGZGTzewPSRacvw6MkW5ZdDv9QseBZFYZaAz6Bn2nVb/ODlWyeT WS6gS4hrgJbcqhuhKr3X9os0l32ii2/0ZnkDsJkATxVFruwNcqdl5pvKMqZD00etq/jb gXxwi3/IsJaU93bNhw94Mc+by7f62EWSpuEeey1rzyFq5Ur7mQp07EWD2D3C2tmVwWIJ SgvLrkgh0UL5tyCXoWwm86olkhdhskg0uOhauBrwxERfujfWGd0v+COG9YFg7oWofQB9 xl/A== 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=huHQ7wQGcrutWiJlcJnxnWvbU6uKiCOCZmwib/4pnSM=; b=xsCxPnVolvui4fol0xySM1EQsPXskS5U/3wBIpor6BPpfAJn3u+xxKTpcpz+s5ryEe nA1ErClHhHH+AkSPLWkz/BSJag0MC7QeKT0R9sJ2GD/keUCfzMc4Z5YCAu3P7H0bewsw Ycp2sY/c/VZ219azSJdlacTJY8Z8mLR5odCvJR6aBeo3I2uvBufcjN3et6F7iT68qjwG gc2k4+eBryD04T1cojcbpGvB/j6rZUqXXjnrBmfJ/Ji75C9QLdkM69toP+DQPUuZ6DJp 4XuO7tHLJZeHNlcdUdFo3ILmRjmgU6UvDP0rFzbO3mIzvvmfi4zjei+fqsZOVfI1co9q 85Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a9OvBcSy; 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 hp28-20020a1709073e1c00b0072b4ad153dasi10583981ejc.635.2022.07.11.18.16.51; Mon, 11 Jul 2022 18:17:15 -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=a9OvBcSy; 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 S231304AbiGLBGl (ORCPT + 99 others); Mon, 11 Jul 2022 21:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiGLBGk (ORCPT ); Mon, 11 Jul 2022 21:06:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDB7F2613B for ; Mon, 11 Jul 2022 18:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657587997; 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=huHQ7wQGcrutWiJlcJnxnWvbU6uKiCOCZmwib/4pnSM=; b=a9OvBcSyfjKC6rYAHsr0VmOFhrSlU87m4alh7llrv10vKBTTsOJYAUYuqPo5ZPeYe7snU6 QyLioeGbD/ITqc30+tdfGlsCx2NWJbhxeFhNrMMc8k1W0Tyjk8eqA55a4KNQnba5F/tbHw 0OUkxN/6+STcto42TLuQHaUsiPcydxg= 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-31-FZlhS81rNiaxZ4ASu3Y23A-1; Mon, 11 Jul 2022 21:06:34 -0400 X-MC-Unique: FZlhS81rNiaxZ4ASu3Y23A-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 0F3718041BE; Tue, 12 Jul 2022 01:06:34 +0000 (UTC) Received: from localhost (ovpn-12-173.pek2.redhat.com [10.72.12.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CCB340D2827; Tue, 12 Jul 2022 01:06:32 +0000 (UTC) Date: Tue, 12 Jul 2022 09:06:30 +0800 From: Baoquan He To: Matthew Wilcox Cc: Jianglei Nie , vgoyal@redhat.com, dyoung@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3] proc/vmcore: fix potential memory leak in vmcore_init() Message-ID: References: <20220711073449.2319585-1-niejianglei2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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/11/22 at 01:18pm, Matthew Wilcox wrote: > On Mon, Jul 11, 2022 at 03:49:51PM +0800, Baoquan He wrote: > > On 07/11/22 at 03:34pm, 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 > > > returns a negetive value, the elfcorehdr_addr should be released with > > > elfcorehdr_free(). > > > > > > We can fix by calling elfcorehdr_free() when parse_crash_elf_headers() > > > fails. > > > > > > Signed-off-by: Jianglei Nie > > > --- > > > fs/proc/vmcore.c | 5 ++++- > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c > > > index 4eaeb645e759..125efe63f281 100644 > > > --- a/fs/proc/vmcore.c > > > +++ b/fs/proc/vmcore.c > > > @@ -1569,7 +1569,7 @@ static int __init vmcore_init(void) > > > rc = parse_crash_elf_headers(); > > > if (rc) { > > > pr_warn("Kdump: vmcore not initialized\n"); > > > - return rc; > > > + goto fail; > > > > Sigh. Why don't you copy my suggested code directly? > > I think at this point, you should just submit your own patch > and credit this person with Reported-by: Thanks for telling. I will consider doing this in the future.