Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1975399ybv; Fri, 21 Feb 2020 06:40:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwyTNDXI5AhSSXH93EIq6laQJ2sGzkGYji0qr3iqlnq0fncOakjFFgzrZfS0zNuIiN3TB5e X-Received: by 2002:a05:6808:b39:: with SMTP id t25mr2245008oij.71.1582296035268; Fri, 21 Feb 2020 06:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582296035; cv=none; d=google.com; s=arc-20160816; b=i/zFSidUFq3jV6e2RpFgEsd2WvL657u6zqEwo6RygmqWl75NDYrYjbocTWBQRopsn0 FRV3CY616/T2WiuMe42nrsRrEauG32AJhXFDHb4iErC0pNngPZwGRwFXIDjTUCQMTB3N r9B1CVMNhl5xyJ/s+NU8nyJOeXmeQOQRNC4PNQYbVDd2lSa7PgsebshTFNChPzPc7Alc 3pLEACE46oV5gkdiPsd7nOwNL0yNl/eQmZpHhQA+ZGnWdJk56SEokGD5ycNawF2hknt0 t3OynjewPk+QaXFMB/cFhKkYWnJ/165cJA8A7020aluCmR2GORierapj96gMkMD37klx YZOQ== 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:message-id:subject:cc :to:from:date; bh=SuQ1BdeuLBrKw8+R08T+pTmDr0MRo89iykSmIvwXGgA=; b=z7BJwQY3bXdSL/LHgZUzA0gB+RiQjvXQc+SF0XU8a0sA3FeTtWYKKe8ySplQ9EQxX2 M0jw0rTdO+H93gsiXlucKdJjTOqaJIuSwXinXYypkqwXtiF+e3ffcmU2vPZ2xeXspALj WEqmfUDTxmUvNroy+xX9Zv5J6Nw99c0xDjoCCWD7CZmUGD8RoJ0Z2BYls2wmF/iEtYuM V2UUnNRYnkxSsu2AxOJmbxY91ECj6aqcbUKrmC9JWtJ03wZ0l8Hj3k2jmNjxsbeM0ZVP 8NnQ6e8ixwzD8+2H0xlySw4IIibb1t+Ss65RfBK6OlGywFL2VZzxx98gGjm3K5vMH4CT PVOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si1514962otf.32.2020.02.21.06.40.18; Fri, 21 Feb 2020 06:40:35 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728858AbgBUOkI (ORCPT + 99 others); Fri, 21 Feb 2020 09:40:08 -0500 Received: from foss.arm.com ([217.140.110.172]:40806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728068AbgBUOkH (ORCPT ); Fri, 21 Feb 2020 09:40:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 153A01FB; Fri, 21 Feb 2020 06:40:07 -0800 (PST) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9988D3F703; Fri, 21 Feb 2020 06:40:05 -0800 (PST) Date: Fri, 21 Feb 2020 14:40:03 +0000 From: Lorenzo Pieralisi To: Dexuan Cui Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, sashal@kernel.org, bhelgaas@google.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, Alexander.Levin@microsoft.com Subject: Re: [PATCH] PCI: hv: Use kfree(hbus) in hv_pci_probe()'s error handling path Message-ID: <20200221144003.GD15440@e121166-lin.cambridge.arm.com> References: <1578350351-129783-1-git-send-email-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1578350351-129783-1-git-send-email-decui@microsoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 06, 2020 at 02:39:11PM -0800, Dexuan Cui wrote: > Now that we use kzalloc() to allocate the hbus buffer, we should use > kfree() in the error path as well. > > Also remove the type casting, since it's unnecessary in C. Two unrelated logical changes -> two patches please, I know it is tempting but it is important to split logical changes into separate patches. Thanks, Lorenzo > Fixes: 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer") > Signed-off-by: Dexuan Cui > --- > > Sorry for missing the error handling path. > > drivers/pci/controller/pci-hyperv.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index 9977abff92fc..15011a349520 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -2922,7 +2922,7 @@ static int hv_pci_probe(struct hv_device *hdev, > * positive by using kmemleak_alloc() and kmemleak_free() to ask > * kmemleak to track and scan the hbus buffer. > */ > - hbus = (struct hv_pcibus_device *)kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); > + hbus = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); > if (!hbus) > return -ENOMEM; > hbus->state = hv_pcibus_init; > @@ -3058,7 +3058,7 @@ static int hv_pci_probe(struct hv_device *hdev, > free_dom: > hv_put_dom_num(hbus->sysdata.domain); > free_bus: > - free_page((unsigned long)hbus); > + kfree(hbus); > return ret; > } > > -- > 2.19.1 >