Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6384505rwn; Tue, 13 Sep 2022 03:35:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7bb3fmMfp8ABl3Jzp5th8IIqtiK5fxVBVcyKsT0SSBp1RZzG+ruZ+NyLr2X7/cLduL/vxg X-Received: by 2002:a05:6402:914:b0:451:22c5:2e28 with SMTP id g20-20020a056402091400b0045122c52e28mr15311512edz.294.1663065309657; Tue, 13 Sep 2022 03:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663065309; cv=none; d=google.com; s=arc-20160816; b=O0d95n4O0vy593t7nRdSzRSjPUOqRblHetYcoi7quRbYIMT+rXB/R+kekMi2WgkHRQ i4z2KEiRZxBDYqJuRUyFW4qO+hfpoPXgZwAWDh2ROXH2wVepM6hNIk00Vc1+gx+EuTxy D3BK7VtiPH6M6/OrA2enveHAX0JZdgRNAr3DDHYI7GLFZZQpc8MKKUdlypKIv0SnmUNe cXDBmu1jomySWR4iY4MtgsloxAAUD+VlsRyp8Z50j65e5Fk//BpO1hAT0viFYINOfpxF ggFX/XuCTfbz6/AuNJMhpd6OopPetM7lCCj8XxERj0MBJILkd0g/zTyPWfnEEY2q3LQz ogvw== 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=haJLEkgrl6AF0f2+tq8m7Wz5y9BoDUUF75cEpjza7qM=; b=De2Z/qblY/sjtcpxcRe6cFBjPDjcO+YCDFN3c2vA9VN1drHrpob6tUo9xiT8w/JYNr T1GXu/Hkq2qqHel3gIQG1oLh8w98/s2IjzquDe+Egd1a2uOyEGG6LQVSiZgwo+2Bk8gP JwA7/6Vxug8sbPzLpwZmQxJoeJcfiWRwzoZDJJiwh5VfuLf8UbUBQ/twLpXyc+lU/knA Tiy7JvxflGsoCCRcEOp+7YDyutotg2jhH/THm8J+x33AHzNQ7+sr76b6N+Ocy0MemoGT L3JTHb2zavzlNhOEtG4ia/lNIg3TAvcV0HEcV3kNNI/NDg30+xLs1cf034NIxSp1UoaU oZ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pm6xmRPG; 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 q22-20020a1709066ad600b00734c8b99826si8021965ejs.803.2022.09.13.03.34.42; Tue, 13 Sep 2022 03:35:09 -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=Pm6xmRPG; 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 S231608AbiIMK0j (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.8 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 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.