Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2215633ybl; Sun, 18 Aug 2019 21:16:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqygdj63xeVXhDGZnRMhKaEm49P6gXcHEWXd4jp0E4NtUX8OUNJQIOqT5T5TnkBWC5L5xrJO X-Received: by 2002:a17:90a:9cf:: with SMTP id 73mr18664551pjo.90.1566188167854; Sun, 18 Aug 2019 21:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566188167; cv=none; d=google.com; s=arc-20160816; b=ss6eZtpLhwNrLAQ/oDrSa+siVNAsnsjvgmZEramn37qWhE7pqce28efRdErJQ6yp1T NgEPI4QgwSDYqpT5tzsZgdn6kkSIp2mqfjsUJTp9Ik7V0HWOz1cA/pUdJWi13m3iDksI CIR5bXEtkpAQ11Ilj3NsaJtSthwPsIoCoGFcRiJKlfHg+2iyuIA/PcHABfH7L/fv00l2 H78upiI7rO0BYsW0v3icwV2mzstjcJb/RXRKlOCLXgPsV5V0ccoK2ksrYZyvxJ42Cjgr +FmCjq5e1mccBDKtQMPuDe4QkUTx0C4SBxkEMDY5n8Zbg35kiPtqfjKY6ebWHwmsWMYf VeUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=x0nxGPuZl6OzRvhI9JteYOTIS9V5/De0DOoCRwbKaa0=; b=cqYfxs7ehtzv/5wzQvQmqZcsx6KfQ+8clOuATkXy4z9KlSDRMHm7euLhEQKmAJSf3z 0UJMt1piSkIRxfDsdEsnFocHZc4i6A65/2pEe45VyrM9TW+6G2gDmQRbqVEDgfKh61zS 9O/fUlDUfOe4VNjol1i/SEzO/fjcHn5Y0kMe4YjwpLX9p7TQBJteAumc9EI61ZzyASVv fdaX3QaE+D6b/bRb79yhheF5JKF0yR2+/AKOXkod5yv3b1lU0nQJ6Yg+am48sjjVjZpm 4s4VSj6SwRYoiPYu8DZor6hDqjGo5IHRdwtz3sxduDbyAl6aYeyGn5J8+xO8IQ1qpRQn 2f7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=diS2vgq1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si9741826pfi.170.2019.08.18.21.15.52; Sun, 18 Aug 2019 21:16:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=diS2vgq1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726281AbfHSEOs (ORCPT + 99 others); Mon, 19 Aug 2019 00:14:48 -0400 Received: from m12-17.163.com ([220.181.12.17]:48714 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfHSEOs (ORCPT ); Mon, 19 Aug 2019 00:14:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=x0nxG PuZl6OzRvhI9JteYOTIS9V5/De0DOoCRwbKaa0=; b=diS2vgq1plYI9D/2d5FjR jHQknkIjEfCb3tBQF62KjBe3nVG5AMpilVTllP5NLmZsa5OxOglJBUSsp3h3kqUu w6MP/qJRK+f9wmaK5E4i5c84ZjGyjs341lAaX4LAC+UY5TL9Kf13r3seh0ETg0r4 98mfjQiCtJ5NswDaIo6Xyo= Received: from sise (unknown [202.112.113.212]) by smtp13 (Coremail) with SMTP id EcCowADHzAkvIlpdvAaPIg--.63341S2; Mon, 19 Aug 2019 12:14:40 +0800 (CST) Date: Mon, 19 Aug 2019 12:14:39 +0800 From: PanBian To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH V2] block/bio-integrity: fix mismatched alloc free Message-ID: <20190819041439.GA23459@sise> Reply-To: PanBian References: <1566176353-20157-1-git-send-email-bianpan2016@163.com> <20190819035613.GC3086@ming.t460p> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190819035613.GC3086@ming.t460p> User-Agent: Mutt/1.5.24 (2015-08-30) X-CM-TRANSID: EcCowADHzAkvIlpdvAaPIg--.63341S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZFykCFWfGr4rAF1fAFyfCrg_yoW8Gr4Dpw 4kKayYkF4jgFyIkF4DA3W3ZF10g34xurWUWr13A34Fy347C3WSgr1q9ryFgry09rWYkrWI yFWYgryqk3s8A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jVc_fUUUUU= X-Originating-IP: [202.112.113.212] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQBAWclSIcBkc9QAAso Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 11:56:14AM +0800, Ming Lei wrote: > On Mon, Aug 19, 2019 at 08:59:13AM +0800, Pan Bian wrote: > > The function kmalloc rather than mempool_alloc is called to allocate > > memory when the memory pool is unavailable. However, mempool_alloc is > > used to release the memory chunck in both cases when error occurs. This > > patch fixes the bug. > > > > Fixes: 9f060e2231c ("block: Convert integrity to bvec_alloc_bs()") > > Signed-off-by: Pan Bian > > Cc: stable@vger.kernel.org > > --- > > V2: add Fixes and CC tags > > --- > > block/bio-integrity.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/block/bio-integrity.c b/block/bio-integrity.c > > index fb95dbb..011dfc8 100644 > > --- a/block/bio-integrity.c > > +++ b/block/bio-integrity.c > > @@ -75,7 +75,10 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, > > > > return bip; > > err: > > - mempool_free(bip, &bs->bio_integrity_pool); > > + if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) > > + kfree(bip); > > + else > > + mempool_free(bip, &bs->bio_integrity_pool); > > return ERR_PTR(-ENOMEM); > > } > > EXPORT_SYMBOL(bio_integrity_alloc); > > 'err' is still reached in case that 'bs' is valid, so fix nothing. You are right! It's my fault. Thanks, Pan > > > Thanks, > Ming