From patchwork Wed Oct 11 08:44:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 115524 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp390170edb; Wed, 11 Oct 2017 01:45:36 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAPNMnaY6Ff6OHBMDe9Mm5itFVHVdNVBTSALKDEc3sui8vT26H4J0mU1xqe92einje3PDxM X-Received: by 10.84.217.131 with SMTP id p3mr14949761pli.126.1507711536006; Wed, 11 Oct 2017 01:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507711536; cv=none; d=google.com; s=arc-20160816; b=PsLpn2ybiIKuvh1cfg5UcUXyzLdmmtnZu7dMcWSewZtRqYE3Uj+SiFpBQ7wEvjpCT4 IbHPaQp482gglEdTx8m/Y4eVS7Iu/EB+UEAs84AXdzymT2nPazxWntaYA6Jz7QD2q9Uj N28Y8MyppdmGAU8l8xQ3udBSYHZyuGjKMGWYTcgrQCEMDrRB4SnqONTjd4RFpCoNOKRA TyV6O4zV4zue+jA4AYz+9bN5QK4DG7LD3yYQM+K89clFVsDsVUlq6A6hP/pMIKJwjRUz gzZ2twqnNyg3qP2Umun+xPc1EfzWa8LxBusDpcQYzs34yAHLgDLocsIgfRXwuVg+ZwWj Hmng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=5qynLuyB+TOd3wJFvwhBWB8KjrL/cH9FY+dQXSi+lSo=; b=rcaq8zHdO2X4MfPnoyWU6FeOEOUsA6qmPAyU+SEzKS5CAR77iMpcwCA+Fj+rS9oRBy xujJ6jwQNdasRJJG6aoVKWppQwcwA3FW/WbnYoC+t0jONBNSGqO+01hbkAZlv91/kJoO gTBTwF/3T2t2IDjfPAVJHAL+JH8DPJQsoNatc54UOf5MxH8OmTI0JFJMZJ8IQOnuseP0 tI4tUqdCTtI9SJ8AUs6w3Oj1ZxGp7u0oETToMnl7WQsm6CVS0eI68xAkDTvk6xyTylRz lyjkGBGeNdb7qJA9oAoTnQ/4RaKwmkNQn1cLowYcGYYJmZbVJj5BYLwamw2ZPGlxtFB7 Pm9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VWK9+EmG; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si10692824plz.717.2017.10.11.01.45.35; Wed, 11 Oct 2017 01:45:35 -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=@ti.com header.s=ti-com-17Q1 header.b=VWK9+EmG; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757332AbdJKIpc (ORCPT + 26 others); Wed, 11 Oct 2017 04:45:32 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:18518 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756760AbdJKIp3 (ORCPT ); Wed, 11 Oct 2017 04:45:29 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9B8iugM008501; Wed, 11 Oct 2017 03:44:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1507711496; bh=2KMQNw9O5Oh07SaiQ3Zo2N1Ide2KXjn+XVBsIZSKkW8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=VWK9+EmG6vbS+P03wAsDaDacrexhw64ruubE8bygN1HcVStg6GVuWJHQERB06jPmH nLKdbL0Z1IG1f3sO6PpKlUUdSQStACYaI4vspMLIYJ9CGYvOuWGNa8pnIi0lmYMG8H XYTLRyudotnQJ6YlIoGuDr/7Bfv0Lli9s0Y8bNPI= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9B8ipBT005908; Wed, 11 Oct 2017 03:44:51 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 11 Oct 2017 03:44:50 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 11 Oct 2017 03:44:50 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9B8ih2r019232; Wed, 11 Oct 2017 03:44:48 -0500 From: Kishon Vijay Abraham I To: Arnd Bergmann , Greg Kroah-Hartman , Kishon Vijay Abraham I CC: , , , Subject: [PATCH 2/3] misc: pci_endpoint_test: Fix pci_endpoint_test not releasing resources on remove Date: Wed, 11 Oct 2017 14:14:37 +0530 Message-ID: <20171011084438.8296-3-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171011084438.8296-1-kishon@ti.com> References: <20171011084438.8296-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) in pci_endpoint_test_remove returns '0' which results in pci_endpoint_test_remove returning early without releasing the resources. This is as a result of misc_device not having a valid name. Fix it here. Signed-off-by: Kishon Vijay Abraham I --- drivers/misc/pci_endpoint_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index e787a63a321a..5cb624b6fa0a 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -551,17 +551,24 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id); misc_device = &test->miscdev; misc_device->minor = MISC_DYNAMIC_MINOR; - misc_device->name = name; + misc_device->name = kstrdup(name, GFP_KERNEL); + if (!misc_device->name) { + err = -ENOMEM; + goto err_ida_remove; + } misc_device->fops = &pci_endpoint_test_fops, err = misc_register(misc_device); if (err) { dev_err(dev, "failed to register device\n"); - goto err_ida_remove; + goto err_kfree_name; } return 0; +err_kfree_name: + kfree(misc_device->name); + err_ida_remove: ida_simple_remove(&pci_endpoint_test_ida, id); @@ -592,6 +599,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) return; misc_deregister(&test->miscdev); + kfree(misc_device->name); ida_simple_remove(&pci_endpoint_test_ida, id); for (bar = BAR_0; bar <= BAR_5; bar++) { if (test->bar[bar])