From patchwork Wed Oct 11 08:44:36 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: 115523 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp390011edb; Wed, 11 Oct 2017 01:45:18 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBRHPZMLHpw+1mhKAJU9+jTEkRXuTfU568WIGmg6MU36p7GNo29j033BwukXlbq3iLT7521 X-Received: by 10.98.7.82 with SMTP id b79mr4431241pfd.289.1507711518678; Wed, 11 Oct 2017 01:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507711518; cv=none; d=google.com; s=arc-20160816; b=OKdCJsRb8fBhlnAgHpaudYoh/ZvqaBGQLLRpxmCJpeg98xEegjx4+lf/h1gMYY9zd6 3uX4Nb7DOd38yJqFbdP/kRNbTu/IWE40ohECNsjc0zawFw8nxxUoWMz5CgvmZdiJijPP ZOlqD83BEOareBRvZbsBz/xiQ31wSYlMnzbUYIMHSnwQ3aBwyZaAWe6auUbNOY2j1Hhx rerutFK5L41yD4r6m03a5AshvwgKJusELU+dHljVtqcd+sZlp8ZG1OwSZTP5UsZwAduF iLEaYoi1qoD5tCwYJ6TrhoC3rW2nid+KMReStZZxRy6svo0Idit3P1tQgLDHhLZphlgY t5jA== 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=Y5xaAQEm1qhCcMJ2zp465d7xcDrzQO+DDr05AnO5qjE=; b=VQjXZHkFKGGk67bBO2+UVd59Bhv62X0lKW/dyCYxScV9ps2VraiZ+t3+BgkeY5q4U9 p79G6bYx8JEzJVqqoTF6I9FJMGMdoffxVglUOHCk8FG4U6Ls32vsn4PiEHTjhqStYQYI I/4ttzoh2JP6lNAOpXMQJ1um7uUvAhaThJkqIWGU6cNHud2NFGVE3a/v6R6/ghYKokij 7S2Re+HlqYNEsWMMYxAmwFd2I9gYhab33E2Q6Pv1cCfgS6uDCPK1mGh2LgVhvFzJ7BGp mnxm9UvgSlIcopQNbHzvG+VNvYBVgyDP6PwaHHTihNythi+yoUR7u0HY2umV+qOuXbMX 24JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V1+nwcr8; 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 y69si123717pfb.303.2017.10.11.01.45.18; Wed, 11 Oct 2017 01:45:18 -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=V1+nwcr8; 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 S1757316AbdJKIpP (ORCPT + 26 others); Wed, 11 Oct 2017 04:45:15 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:14420 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756774AbdJKIow (ORCPT ); Wed, 11 Oct 2017 04:44:52 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9B8im2n011180; Wed, 11 Oct 2017 03:44:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1507711488; bh=mtndcPpg4InTr9/CibtyEBgwD00K960WFfof6Gtu4iY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=V1+nwcr89/pTAbriNts53rYfi7CkYLywIRkaqfruEU01HWSPOAw1c2BU8TpC09aeg OQQLHxRqFz1LEZ1MuywWtRvSr2PJzj0ppW0xPvCjGhLvJ5Ao2y5SWeMK2bIGotNVCo khlsIXxwYDCY2MLeAK1lik+giMvjo66TMGhtFBmw= 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 v9B8imBC005892; Wed, 11 Oct 2017 03:44:48 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) 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:48 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE104.ent.ti.com (157.170.170.34) 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:48 -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 v9B8ih2q019232; Wed, 11 Oct 2017 03:44:46 -0500 From: Kishon Vijay Abraham I To: Arnd Bergmann , Greg Kroah-Hartman , Kishon Vijay Abraham I CC: , , , Subject: [PATCH 1/3] misc: pci_endpoint_test: Fix failure path return values in probe Date: Wed, 11 Oct 2017 14:14:36 +0530 Message-ID: <20171011084438.8296-2-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 Return value of pci_endpoint_test_probe is not set properly in a couple of failure cases. Fix it here. Signed-off-by: Kishon Vijay Abraham I --- drivers/misc/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.11.0 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index deb203026496..e787a63a321a 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -533,6 +533,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, test->base = test->bar[test_reg_bar]; if (!test->base) { + err = -ENOMEM; dev_err(dev, "Cannot perform PCI test without BAR%d\n", test_reg_bar); goto err_iounmap; @@ -542,6 +543,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL); if (id < 0) { + err = id; dev_err(dev, "unable to get id\n"); goto err_iounmap; } 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]) From patchwork Wed Oct 11 08:44:38 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: 115525 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp390415edb; Wed, 11 Oct 2017 01:45:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCWRWSrjGLnzRlZtLDZY+M3kAfF3s5XvLczwenVuk0ahjJGlHHZlTHpTCjrzvzP2FhOrtA0 X-Received: by 10.84.137.129 with SMTP id 1mr14980023pln.376.1507711558563; Wed, 11 Oct 2017 01:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507711558; cv=none; d=google.com; s=arc-20160816; b=QPQiKp21AE08p06vJikZnUxUV1sPjVwTe4Vcc1Q1TCQ9JgdPAAGesalaSrrTZUuSBe PM426FD4ohioUlqWJCN+yugO30N3sfce99c1PmKrNTJfeOhJl4lmRjpIuge/y1uNgtLx H5mXu3Uz2aWP5MbEWr8ynEMDJxlOTXRR2yPC1nIJCyS+h2pe4y3umIJsO6S4STSmdtSr PFNAzayRLsr2n+5NiVDhS+8BdCSAFeV+PSga0lNc3mnRSpgbsNXC7rcFGLIrudWbcayn DeTlGIKEgRxFFSVSCE0LMe7iYdQdPaYg5wS3aPytXbjYHkwTB2FQX79ujmfMebINZQ03 ZPMA== 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=77TKev0JrNx+UbnS8SBBEK6Vug8DcQv957RLKZUSy2M=; b=PqgkdG5FVHW5ThXb5EkCLKRXC0axiU1rBUEm8E1ty70ygCHsAB3cd8ZiLDEJH4uxri kMlQzHeRNpFBJ1+fVw48hj07uOFJ7DFG+jfNaIjSM4yXk3CESpUO3zuYjSynG6EKA5uR 5MM6l/Cah7KeThTCaw9XeXFhHdM1hwF6K8YCX4RUcfIrLhL7K/X+H8KlwgS8tUq44t40 eVN9mje9qppwIUW0KojDdWybSK6yuU3uwldrpqggvVrY6XdGtjmIVyXdrxqwnnaUJxIA U4oAdJDSnBtOw/lsw4H96PytCzf2FESrFEcK0wErkg1d2/MHe8QZCzq2egRNCCdwwNWl Fr0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hOJsMI3T; 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 v7si10315528plp.471.2017.10.11.01.45.58; Wed, 11 Oct 2017 01:45:58 -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=hOJsMI3T; 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 S1757345AbdJKIpz (ORCPT + 26 others); Wed, 11 Oct 2017 04:45:55 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:18521 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757317AbdJKIpb (ORCPT ); Wed, 11 Oct 2017 04:45:31 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9B8iwLI008509; Wed, 11 Oct 2017 03:44:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1507711498; bh=sYkmQ3U2A+2hYFLaaV4nmHBFP+WPQz70s0Ek/fhDES8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hOJsMI3T2J7KElo0SIhwtt0v7+PKZt+P3s+xdNFFWmRdvFAS38TcbqvEKc2CtSv6E T555Q8krw6bqNJpoJ2TzUAmQ2uV4wDBw26nPE+1V03PACJsBzPGJhDsdwSOILnaYmL R4S5GM81hUXAkbgDcqZi44ceL0ukinDZ2tezTmhA= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9B8irCJ018024; Wed, 11 Oct 2017 03:44:53 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE106.ent.ti.com (157.170.170.36) 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:53 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE101.ent.ti.com (157.170.170.31) 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:53 -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 v9B8ih2s019232; Wed, 11 Oct 2017 03:44:51 -0500 From: Kishon Vijay Abraham I To: Arnd Bergmann , Greg Kroah-Hartman , Kishon Vijay Abraham I CC: , , , Subject: [PATCH 3/3] misc: pci_endpoint_test: Fix BUG_ON error during pci_disable_msi Date: Wed, 11 Oct 2017 14:14:38 +0530 Message-ID: <20171011084438.8296-4-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 pci_disable_msi throws a Kernel BUG if the driver has successfully requested an irq and not released it. Fix it here by freeing irqs before invoking pci_disable_msi. Signed-off-by: Kishon Vijay Abraham I --- drivers/misc/pci_endpoint_test.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.11.0 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 5cb624b6fa0a..086a7f85c2c0 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -92,6 +92,7 @@ struct pci_endpoint_test { void __iomem *bar[6]; struct completion irq_raised; int last_irq; + int num_irqs; /* mutex to protect the ioctls */ struct mutex mutex; struct miscdevice miscdev; @@ -504,6 +505,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI); if (irq < 0) dev_err(dev, "failed to get MSI interrupts\n"); + test->num_irqs = irq; } err = devm_request_irq(dev, pdev->irq, pci_endpoint_test_irqhandler, @@ -578,6 +580,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < irq; i++) + devm_free_irq(dev, pdev->irq + i, test); + err_disable_msi: pci_disable_msi(pdev); pci_release_regions(pdev); @@ -591,6 +596,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, static void pci_endpoint_test_remove(struct pci_dev *pdev) { int id; + int i; enum pci_barno bar; struct pci_endpoint_test *test = pci_get_drvdata(pdev); struct miscdevice *misc_device = &test->miscdev; @@ -605,6 +611,8 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) if (test->bar[bar]) pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < test->num_irqs; i++) + devm_free_irq(&pdev->dev, pdev->irq + i, test); pci_disable_msi(pdev); pci_release_regions(pdev); pci_disable_device(pdev);