From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07D7C54EE9 for ; Tue, 13 Sep 2022 10:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbiIMK0j (ORCPT ); Tue, 13 Sep 2022 06:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbiIMK0H (ORCPT ); Tue, 13 Sep 2022 06:26:07 -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 ESMTPS id 2454E5C377 for ; Tue, 13 Sep 2022 03:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663064765; 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=haJLEkgrl6AF0f2+tq8m7Wz5y9BoDUUF75cEpjza7qM=; b=Pm6xmRPGHU4aSEEJkEXxufb7Z0lQHDM8SK0pZY/JyeBxNT15yhpmdpBDtLLVQ3w1YCCmQJ YRdamoJLSHM6nrK6sHl86s6CaekFXIaU8FxAJ5hUQrUjaFsdo5qsKYCcwnhCq73jCW7T3i pZDr8D9lY89dLMgd/DmjrE4RTzCuGDQ= 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-635--orak3MgMIiwkt3zC2ek5w-1; Tue, 13 Sep 2022 06:26:04 -0400 X-MC-Unique: -orak3MgMIiwkt3zC2ek5w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCD048037AC; Tue, 13 Sep 2022 10:26:03 +0000 (UTC) Received: from localhost (ovpn-13-136.pek2.redhat.com [10.72.13.136]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 174751121314; Tue, 13 Sep 2022 10:26:02 +0000 (UTC) Date: Tue, 13 Sep 2022 18:25:59 +0800 From: Baoquan He To: Matthew Wilcox , Jianglei Nie Cc: 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: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/13/22 at 07:35am, Matthew Wilcox wrote: > 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. Right, that will cause problem. It's my fault since I suggested the current change. Jianglei, please use your v1 change and post again. Sorry for the incorrect suggestion.