Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1089054ybg; Tue, 2 Jun 2020 00:43:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD5W7/r6OaHX8H0GjUfSgY340eu3BJElD52cQuGCpCht/bwSWuhv/StiwN7aTKk2Rydwe1 X-Received: by 2002:a50:9b13:: with SMTP id o19mr19911904edi.143.1591083792436; Tue, 02 Jun 2020 00:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591083792; cv=none; d=google.com; s=arc-20160816; b=NPGExNy/T1NJ2xSh+hsfBStrsuq8M1XJ3EQaiyATC/Ude59JTq0l5ZWDxOEBl/FOXc DJDAS0+9TGNw4fPzVURoxYk/lePOzIXNuNjwmnHfPTp4Lq9sJ2xvJMwdexEl56xyGr4e nRtMe9ixrdTcI3DcP0ssbB7ztPgnlRXvez4YXqDUGBXar0PkYaAIWYU+PCy05ICPLgaB H1a48+WeeyEYi2iZ9UUnVewlI+koV3MXG51RvU3/i9g8HXzr2dntkOD0Vy2wjs93y3vq IVuJOWDioMi/QtnON4Ykeiz2UfTe6qzq1wA6/px9f8pGqBvMlaiSpqqmWu5hDUmlRLU+ wZ6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HSlpXWkdenCoS8Vggi65kLvpKKRyegY2MHdYGB2V1Mg=; b=ySpc2O9vhlWxntNYzOkywrrumKZB4SbOREO5xCaFdfS8qAlzgY6a3fVQwxuS/sP+Rc 9jrZb0YADfhtU5n568BYICgw89dA5Wzcz2gA2WLY+KipNdJNdY1GsWRJN25r8Jj9EQzy deX0Ra1SExhtseSGdETHkqb953OEYMYN7u6E3J/f+lsOTxAW36Z0GDF6NGOmbwI1Gyny AqAjSIHQkLg18AXQIDJ7KRcUYLE1rC73zDNIM3IOPbBkCla+CuA5R2/TWBRrwpvRdxqL 8kj9vHpE9BOPs8Qch9J4HABzqscS4w29FofsSW26HC7/Lexe2TR71pkXzKjLTo2uhNab Zduw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YCruQkWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo18si962622edb.450.2020.06.02.00.42.49; Tue, 02 Jun 2020 00:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YCruQkWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726342AbgFBHiK (ORCPT + 99 others); Tue, 2 Jun 2020 03:38:10 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:50260 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725907AbgFBHiK (ORCPT ); Tue, 2 Jun 2020 03:38:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591083489; 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=HSlpXWkdenCoS8Vggi65kLvpKKRyegY2MHdYGB2V1Mg=; b=YCruQkWo2UsyMXeJOVl9RZ1bdApZs5dhB5PRZnbrVVZpJtbfmbKDfeOrTftTKltF66t+R4 nSmHVJV2PmfX1yAnKwDpIRPdoo3WFeENz/Bict8RPEn5xf6ku69lHPLoA0hwd/LwK63xqN O3zddoNpAH9uI63pdJM0mux0U0t3utA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-1miAQknoOuiCWtiUVJoR4A-1; Tue, 02 Jun 2020 03:38:04 -0400 X-MC-Unique: 1miAQknoOuiCWtiUVJoR4A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D127107ACCA; Tue, 2 Jun 2020 07:38:03 +0000 (UTC) Received: from T590 (ovpn-12-167.pek2.redhat.com [10.72.12.167]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE35478EF4; Tue, 2 Jun 2020 07:37:56 +0000 (UTC) Date: Tue, 2 Jun 2020 15:37:52 +0800 From: Ming Lei To: yu kuai Cc: axboe@kernel.dk, martin.petersen@oracle.com, wenwen@cs.uga.edu, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com Subject: Re: [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed Message-ID: <20200602073752.GB1384911@T590> References: <20200601123856.3895734-1-yukuai3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200601123856.3895734-1-yukuai3@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 01, 2020 at 08:38:56PM +0800, yu kuai wrote: > commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add a > kree() for 'buf' if bio_integrity_add_page() return '0'. However, the > object will be freed in bio_integrity_free() since 'bio->bi_opf' and > 'bio->bi_integrity' was set previousy in bio_integrity_alloc(). > > Fixes: commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") > Signed-off-by: yu kuai > --- > block/bio-integrity.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/block/bio-integrity.c b/block/bio-integrity.c > index bf62c25cde8f..ae07dd78e951 100644 > --- a/block/bio-integrity.c > +++ b/block/bio-integrity.c > @@ -278,7 +278,6 @@ bool bio_integrity_prep(struct bio *bio) > > if (ret == 0) { > printk(KERN_ERR "could not attach integrity payload\n"); > - kfree(buf); > status = BLK_STS_RESOURCE; > goto err_end_io; > } Looks correct, and it relies on the fact the 1st 'page' is always added successfully, so 'buf' is always attached to the bip since then: Reviewed-by: Ming Lei thanks, Ming