From patchwork Sat Feb 22 05:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 1242379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=PBb0jSgu; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48Pd3f1r4zz9sPk for ; Sat, 22 Feb 2020 17:00:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726230AbgBVGAm (ORCPT ); Sat, 22 Feb 2020 01:00:42 -0500 Received: from mail-eopbgr680134.outbound.protection.outlook.com ([40.107.68.134]:5153 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726053AbgBVGAm (ORCPT ); Sat, 22 Feb 2020 01:00:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZ3nD87NQKFeoI59KwNKaJonYby35Xm1b3J/UlgIwmsYvA9mwiMZfp7QT4qTCifGhizenTVzAzYwZQDWN4qnloizixdyZWJwcmvWsEHOC5rUofG8gSKPgK+TyrLtlzrlSVQsLNGKIPBOA4ivp1H18wQOF6HmLrCyZ+4N36+KvuaQe6Fy2oqrN4wGFvTW9PkjVKeBQ6dgSfDFh8/aEjIgOplDK2qypMcR2dZGI7QfzLtJLPO4RlzFAFEe0eUDWfzayAE/paWTIMrjjsMUnZqXMeV+8I3F+nyjVrp8p3+mr1aPy9igQBP1VOL4IA677hWCFEQ9WRpffhj3oK873FIreQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sVfGPXOnjJ7gkW9g2nEcBnQ3/ZOoL/YqiMF1B12XDho=; b=kO/pcWUcwyIHjK3I1RqRT5pzgj7DeFZcLdNl+fbucQg7iW4J58ExaQemdN9GOepuYd8n1KhgKb64tLJ9GoJwzp2hfJ/g902HLmr5VnBMzO/uhawYXD4Pr2QtfEmiLW808kY+i93PK5NEkSKJWF4fikSprf4L2dDZ6zoazDYCtldVGw71cr5Q1mlNlmA18NThotHrIkJTDqn5gbDzokSGoBYQdt/uYvQ7pATaL2ZKw+xuAYLGKRlMjapxeKctWqK+DGQ76h5eC+fX2HgNTlskVrNSazIw+Fug9EfbiSoIBlLSKdmEZ0nsy2vDdHzAc/yBFKI6oxEhQpP6Sf5R5mGlUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sVfGPXOnjJ7gkW9g2nEcBnQ3/ZOoL/YqiMF1B12XDho=; b=PBb0jSguSr4yTCqhMTbot5RUASGMNdFisHT5L/LxMHaIG4Yb6fqscOd6x8Z7jccNEfUVSMcvm6UXkgUZ7mkoQ9dJeCFprOjXlzHCruhoxv3GQAqST2DZjsmRWWyDeFG87T02fVgh9GvocbJecQLZ79x9AVy6TM75hI4b1gFCIMI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; Received: from BN8PR21MB1139.namprd21.prod.outlook.com (20.179.72.138) by BN8PR21MB1249.namprd21.prod.outlook.com (20.179.74.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.5; Sat, 22 Feb 2020 06:00:40 +0000 Received: from BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::18c0:bfd0:9181:4c62]) by BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::18c0:bfd0:9181:4c62%8]) with mapi id 15.20.2772.004; Sat, 22 Feb 2020 06:00:39 +0000 From: Dexuan Cui To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com Cc: Dexuan Cui Subject: [PATCH v2 1/2] PCI: hv: Remove unnecessary type casting from kzalloc Date: Fri, 21 Feb 2020 21:59:56 -0800 Message-Id: <1582351197-12303-1-git-send-email-decui@microsoft.com> X-Mailer: git-send-email 1.8.3.1 Reply-To: decui@microsoft.com X-ClientProxiedBy: CO2PR04CA0117.namprd04.prod.outlook.com (2603:10b6:104:7::19) To BN8PR21MB1139.namprd21.prod.outlook.com (2603:10b6:408:72::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (13.77.154.182) by CO2PR04CA0117.namprd04.prod.outlook.com (2603:10b6:104:7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2750.17 via Frontend Transport; Sat, 22 Feb 2020 06:00:38 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [13.77.154.182] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d742a3f7-c305-4962-34a4-08d7b75c8aee X-MS-TrafficTypeDiagnostic: BN8PR21MB1249:|BN8PR21MB1249: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 03218BFD9F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4636009)(346002)(136003)(396003)(366004)(39860400002)(376002)(189003)(199004)(26005)(8676002)(186003)(316002)(3450700001)(81156014)(5660300002)(6666004)(6512007)(16526019)(6506007)(2906002)(81166006)(8936002)(478600001)(10290500003)(4326008)(86362001)(36756003)(66556008)(2616005)(66946007)(52116002)(107886003)(6636002)(956004)(4744005)(6486002)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:BN8PR21MB1249; H:BN8PR21MB1139.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NkmjmcfvVeahwbpeO3AeS/9XGlFLuZqZwU4avS8pKVRobRLAlkuh0Px+aJp5ldCnBew5M8FP4Hh/lUBZmqUqSrbfXykjmM2YG85CzIt3uncFWxO4IA7y+AUrQnq95AcplCslh5hsWSsxNnvAzv05vG8a5lIvEPzYklSi7hWHag8zL6THiUAvVOdbjM7QkH1rbB4An2mz4Pxb4v4LWc48PSHP60aFZHsS8xuScShDwrnB9AYzkv5Y/W2gfHhr14sK0bRZ60e9qCTieu9cxHpPo/bxCvLu3bVCdaZQtS4757wGr5QJlAs5n/hJ9d7vIpLlFcHS0o9Afbbr2kDv8yLghjdERcVIkTzyD90v+BT3iXuLBSbXPJWjpGbdTYEQljO2b6SKoJopHY68VHesOOeHrOv82A14wt8mHmtHgYtijyh1JuwcUIqvKl0JxRxlkBYP X-MS-Exchange-AntiSpam-MessageData: z4/rMeGl9PMt7PCjhBSdzqxk+scwIMcQkFaH5q37gA8vkdZygDrRdrTA8rgptMHdwSqXG3Ls0dc+Mj0JDmSRhfQ8ScEmZU9g+1SSmL/xEjx6eeL/yzNQyABeBvYIVjljg7ORHv4I3EJNR/VDC+MraQ== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d742a3f7-c305-4962-34a4-08d7b75c8aee X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2020 06:00:39.8581 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sUT2eLtxrOKsny9dn6VUMvPobOxHTClFsQRRFKd4Mja5bO7JBxgiE+OKUsxwnpqBN5Mtrw6zalYkhI4xunKilw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR21MB1249 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In C, there is no need to cast a void * to any other pointer type. Fixes: 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer") Signed-off-by: Dexuan Cui Reviewed-by: Michael Kelley --- Change in v2: this was part of v1. drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 9977abff92fc..0fe0283368d2 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; From patchwork Sat Feb 22 05:59:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 1242380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=YHRDTg6r; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48Pd3t4xkfz9sRL for ; Sat, 22 Feb 2020 17:00:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726053AbgBVGAr (ORCPT ); Sat, 22 Feb 2020 01:00:47 -0500 Received: from mail-dm6nam10on2092.outbound.protection.outlook.com ([40.107.93.92]:7935 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726892AbgBVGAr (ORCPT ); Sat, 22 Feb 2020 01:00:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kvKL1FACf9bvnRnQIdz0CD6+y7XbPn48UQ5rdPRkwNVyGV17mcblWpuKWTMxGfil9HAosXZ3N4ev5gZSKy3JMlHaTHQIZ8iXdFsxSRV6LGILjvmNBF5hMetgMwNWxglbXjEpMS/U/qVzw1fDQxOg8L6vlQ2O7Bc7GbykW2UQkS2ixsKSHz+/XAaqPrENzVL4IL1HqAs9BLFeH9Ov0nVJGW4wlPUJJdkRGkGyI1bOHjeGg1IJzdmQu8K2V+eHTtzVWHRTGSw7gevJ8fmeBGoAqMhI78bMMK0yUqjzFjFue5zmstB4J5zzKUeoprH4RDC4mC3tUg5fRICCyFJ5gwklQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nnk/aPUxC+GGxB30HOxEVgj2VHoKv7y1lL/Co1ZgWXg=; b=B1U3hKpjWfSktPH9Cx9Em3AiXRpIlY+3HMZkdzkTxKwNB5uDOfkDoEmybepZfBld21fLaYeMLmCZP5P+tXIaXyiUZDtjRtUwZe9zYYLPIZKnvqm+ph01MKx5UwXimerhiUoSM8O0zNPte+7uSQYM/M5lPchpCb0ulsMK5Rzm1CDVdnHAnzuUJ4UhVbHrOExICOxuK9fS8pBxkDby4l5Kun91/lVodPpqXIOrdASCXf6SSh/rLYiS37Mp8fd/JpC9YJ2voCebn1306CCjUIeg+RgPRrOBkHRHFyEVVoe3LdgK1Ch3XUOQoEz2SOwYrfK5Gof9EuvhrZ+ZxDujuJrz2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nnk/aPUxC+GGxB30HOxEVgj2VHoKv7y1lL/Co1ZgWXg=; b=YHRDTg6rxIhUAJdvGCb1eHwYMU+EBeV1mHylBIph+x/UDx+1xr8kw+/v2/k7TUflg8C6WlosZntHs6ArkBISlk7PJJbixhubk4s3W8x0lCLP38urLt/LpRN8vg3BROkzevhzcx1GWb8GbIbX6UvIvOhboQcsxCAYOGFkj2lEWu4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; Received: from BN8PR21MB1139.namprd21.prod.outlook.com (20.179.72.138) by BN8PR21MB1154.namprd21.prod.outlook.com (20.179.72.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.5; Sat, 22 Feb 2020 06:00:44 +0000 Received: from BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::18c0:bfd0:9181:4c62]) by BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::18c0:bfd0:9181:4c62%8]) with mapi id 15.20.2772.004; Sat, 22 Feb 2020 06:00:43 +0000 From: Dexuan Cui To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com Cc: Dexuan Cui Subject: [PATCH v2 2/2] PCI: hv: Use kfree(hbus) in hv_pci_probe()'s error handling path Date: Fri, 21 Feb 2020 21:59:57 -0800 Message-Id: <1582351197-12303-2-git-send-email-decui@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582351197-12303-1-git-send-email-decui@microsoft.com> References: <1582351197-12303-1-git-send-email-decui@microsoft.com> Reply-To: decui@microsoft.com X-ClientProxiedBy: CO2PR04CA0117.namprd04.prod.outlook.com (2603:10b6:104:7::19) To BN8PR21MB1139.namprd21.prod.outlook.com (2603:10b6:408:72::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (13.77.154.182) by CO2PR04CA0117.namprd04.prod.outlook.com (2603:10b6:104:7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2750.17 via Frontend Transport; Sat, 22 Feb 2020 06:00:41 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [13.77.154.182] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 782a057e-53bd-4125-9784-08d7b75c8d02 X-MS-TrafficTypeDiagnostic: BN8PR21MB1154:|BN8PR21MB1154: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 03218BFD9F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4636009)(366004)(346002)(39860400002)(376002)(396003)(136003)(189003)(199004)(8936002)(66556008)(8676002)(66476007)(36756003)(66946007)(10290500003)(81156014)(478600001)(107886003)(6636002)(81166006)(2906002)(16526019)(186003)(2616005)(6512007)(956004)(5660300002)(86362001)(4326008)(52116002)(4744005)(316002)(3450700001)(26005)(6506007)(6666004)(6486002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN8PR21MB1154; H:BN8PR21MB1139.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PkD/a0fCCy+UARzIKCbZC+/JAsI/2E4alaUHNr4UwplMaXwq9PqYXxssg/lubqrrgjKWjAV0GPTQ71Np7SqPqdImuPgJ6RzA/YifS8vNmPmIRymLDeuXq8Fh/3IslLevYCKPvaNjwJsYbTE2nICBcU7fJGQGlwq7MIznLhnuy4+IftIwwowcC1vbKJg5/9+ZpqSl+ml38mr2xRvUAWR7TaOOBHxXp14qPmelbeDXqq8YIlVE+gFUuUq4oTqCMozABTwLMVL7U/XFs8Y/QwNpNpDycIilAKcKIyyLltTTsIqDDtaKSud9PhytnCY9mel+w4wBP+XeIgQKnM68yRTRn6dCUni3f5t3TXBntdC4dAWC+ZYEMLPph3qx73cxSBYfmRu0J8pGEG/ruO0L37rGtEXoUHDUTFq9Jqq7KYFCm0IPvfUKrp6MaEWlLCrPu0tJ X-MS-Exchange-AntiSpam-MessageData: k3dfGmysRSeA8dvNgt1gLW8qdy3ql45kIBjKROXhrHKp6nYHtZxnjBDZd+ngo3q+qGjaEGf8yQUh3BJRJCppMx4CeDRy/PazkLfRjKSbFVEhlVloRTg3oct40Tj/6kbzf2FedNJTxYL+JV75Bv4X1g== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 782a057e-53bd-4125-9784-08d7b75c8d02 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2020 06:00:43.5821 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BFkeo/DL+ck3sMeVqNW+G3TADfnf4H79+PcGaN6abGsaE23vRr02S4XiK5xxZUz1budEDGwajuONtadKIGraPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR21MB1154 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that we use kzalloc() to allocate the hbus buffer, we should use kfree() in the error path as well. Fixes: 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer") Signed-off-by: Dexuan Cui Reviewed-by: Michael Kelley --- drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Change in v2: this was part of v1. diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 0fe0283368d2..15011a349520 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -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; }