Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6194761rwn; Mon, 12 Sep 2022 23:46:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5I1noDMVId9fumy3OaL9R3k8zN4xDQa+R5Tsz2Q57280Bvea9YTZ16gyFADo8fsb7OPamG X-Received: by 2002:aa7:ca50:0:b0:44e:973b:461e with SMTP id j16-20020aa7ca50000000b0044e973b461emr24688623edt.414.1663051602317; Mon, 12 Sep 2022 23:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663051602; cv=none; d=google.com; s=arc-20160816; b=FbSF+w8x73YuSgVL2qTOcIPpqxWQlBMOYhW+fU4KNJPyzwfEQ1WMd5hvJiZGP0poPW LcZ7Il2wqsexwVRN3XSKc2AqQNF/i3yhLw4vKePxJ2rXOTvv6C8ZMczHywRRQYckn1BB Emj7NDPolWf8tauKCKMJjAWETh1CXcKkKeyMSOyqOZDmgR2MYrkPeH9jtAmYlKP8vLoA k0oD7StEJrbdUtuBmkf5B46XedxVugTodmH/Cgdx8Q5LGkTSLkBQHieyBuzDVy0vk2KD ksfxFu9JbgflrUkhjGVZNPytIvbNa0/pi3w8zHLESMh/cMXHhibbkXlc00a/zeFKg1mu W5kQ== 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=URvJwIGuP97ABBt8+HgWagxhk5MVBssXZoiF39WbDV8=; b=qVllRVB6FHqBDEv0t/HvsjiIgmZQRkNINLDTfWL19EgtOWbSsg2FYkgdTgeDrrJ73/ Eq5JpuhkM0gsevgCeqchCnjUtrVdJFPc8LchbveaWVQ+cfY3UtF0lvailUiHAheknBmg nWLJaBEQ+1gw0IhJMXHxbhtLEVIiEUUEFpFMeXUfXaaZcPiJn+BxqUAYmiysZ/z96wA/ gsJpxr2Xh+CW0fiVmbQIuaw0XtZvDozuabfFEGvtTFjfyNR0/XcalUBIFciHauSIHL1y jPKnXtJYxI0OI5k5OgpX3o7o3N8LuSXeByaBITg0SECmbjST6lBKAMf09EqHuWycuURB aIQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=djBs1tFn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a05640225c800b0044e7ba203dasi7882364edb.614.2022.09.12.23.46.17; Mon, 12 Sep 2022 23:46:42 -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=@infradead.org header.s=casper.20170209 header.b=djBs1tFn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbiIMGfm (ORCPT + 99 others); Tue, 13 Sep 2022 02:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230394AbiIMGfj (ORCPT ); Tue, 13 Sep 2022 02:35:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC1D71583F; Mon, 12 Sep 2022 23:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=URvJwIGuP97ABBt8+HgWagxhk5MVBssXZoiF39WbDV8=; b=djBs1tFnbBGK7QjEVhVFhoShmk oT5PaiW8JImMUkBJk97/7OgsY/wPsQZmBuwd5dMJ0kENXy+Y0+NpR3wYM8BGXDsciw9HxqnB1rxXg UISsSicLzm1RtnkdqqXdMYpGoyzsWe24Z05VR4VdKc2xalYt2lEmYRPenvc8QsQxw2ZvKOaY+e8Gl CtCkF7qEqZFn6I/8bDxOZz3mMAvqZCLD1uPtNFsxgJ31K4oGxmEf+7KoQRwB5TFcVBy35j2Hs0swY yWQALJky+hrEMy5fsFXIzpgif+DzxQoK+M/HWAnOQelb0MjWd5Qc1sBCEGrautpRls/hVMsGfy+Sg IwB5j7qQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXzVt-00GeRn-HV; Tue, 13 Sep 2022 06:35:17 +0000 Date: Tue, 13 Sep 2022 07:35:17 +0100 From: Matthew Wilcox To: Jianglei Nie Cc: bhe@redhat.com, vgoyal@redhat.com, dyoung@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] proc/vmcore: fix potential memory leak in vmcore_init() Message-ID: References: <20220913062501.82546-1-niejianglei2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220913062501.82546-1-niejianglei2021@163.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Tue, Sep 13, 2022 at 02:25:01PM +0800, Jianglei Nie wrote: > } > - 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; > } Did you test this? It looks like you now call elfcorehdr_free(ELFCORE_ADDR_ERR) if 'rc' is 0.