Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8014396pxb; Fri, 19 Feb 2021 05:26:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/gSUTMGUMIG8UU/yC5EB2bBQxBJIJ7F3ztByzE+5IjyXDLEyeBXqVFRrKkpp7FAbmgpmQ X-Received: by 2002:a17:906:2a06:: with SMTP id j6mr8389309eje.164.1613741197591; Fri, 19 Feb 2021 05:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613741197; cv=none; d=google.com; s=arc-20160816; b=1EkAOVFjGxQEYbJu8HbHbFl4sbBAjKpZt9A3mFxzzuO8rJ3vkmmI47J5Nu+g4ozt+g s1SAPl6kYGYfwEK1KGbfGu7PDsWBm9PgIVwRY8UXeyiuxMhTqlLJTve0qgbnMLd8d5P2 kWgYRQEhZS06HRfXg55uwQk4EMx3JlTNNCCDw0+x2nDBHBA8tWFiogy3fAMeEexTXZkk 8DvtUD8zuGsRzDRz0S6GjV/vLnMBQmva/pEzAE29cm80z1JLgpegUQ4RMjhSuLnK+vhP k08B/5j1kTC6U0m1llRaCoYaaaWruJ5d3O8zwynncNYRO7JcQFnU/FVuVfaJdgR1BMlK m7Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:ironport-sdr:ironport-sdr; bh=pgXJb6Mv7Y4cpKiipR5q+1hlERVnzgnn4KX3C1yU4Hs=; b=S/lP8Ua8+W+fdTQPfj0dnLDc0iqAEEeX4TGbyUtJrr6wESUpUEsWp52atltZnpcgPf IjmNQHodrSuMcVsXzjMay3DWec2r1ROEb4Coevpg2WNX7cOlF6+rDQCexW3bwmM1CB+w hIk7X9BdC9/IUjy+WVrrif3CbR3WAXS/FMSJ4LypncVO1N10ATONLmvm5XQCmalHXlwO ceGKR7VMAM/LWf5oD7eqN4mLW518uzmVgxG0qO0QfOOwtkfb8Y6/MaYbV1s9MtDp8wYR uL8AUOHmXBUTg+lJIc6Q7x4cENDSShGqeIIo5cpvzlP58m2dh2auOddifoR9z1l8apg/ Aj2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt25si3229223ejb.648.2021.02.19.05.26.12; Fri, 19 Feb 2021 05:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbhBSNXK (ORCPT + 99 others); Fri, 19 Feb 2021 08:23:10 -0500 Received: from mga02.intel.com ([134.134.136.20]:47395 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhBSNXI (ORCPT ); Fri, 19 Feb 2021 08:23:08 -0500 IronPort-SDR: loKQ7QdP5Aw12qRDC7FBheez+Y0EyMlDg3jaoNlJhDeqZNnG8j8g7HDWMPehnRNwyXoVZ/fPxt 4n52d00IhSSw== X-IronPort-AV: E=McAfee;i="6000,8403,9899"; a="170967301" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="170967301" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 05:21:21 -0800 IronPort-SDR: 3q8hi1rFIVObABHTdIvXWQsb7hE6eyKB8Ko885U9Tjr4mUp0S+fE5oX8095Rq5u6jmpnDVWmlF iD9uZ9AMe0gQ== X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="386910992" Received: from gna-dev.igk.intel.com (HELO localhost) ([10.102.80.34]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 05:21:19 -0800 References: <20210216160525.5028-1-maciej.kwapulinski@linux.intel.com> <20210216160525.5028-2-maciej.kwapulinski@linux.intel.com> User-agent: mu4e 1.4.13; emacs 26.3 From: Maciej Kwapulinski To: Andy Shevchenko Cc: Greg Kroah-Hartman , Arnd Bergmann , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Linux Kernel Mailing List , Linux Documentation List , Tomasz Jankowski , Savo Novakovic , Jianxun Zhang Subject: Re: [PATCH v1 01/12] gna: add driver module In-reply-to: Date: Fri, 19 Feb 2021 14:21:17 +0100 Message-ID: <85blcgw5v6.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy Shevchenko writes: > On Tue, Feb 16, 2021 at 6:11 PM Maciej Kwapulinski > wrote: >> .... >> +err_clear_master: >> + pci_clear_master(pcidev); >> +err_release_regions: >> + pci_release_regions(pcidev); >> +end: >> + dev_err(&pcidev->dev, "gna probe failed with %d\n", ret); >> + return ret; > > These are all completely redundant. > following is refactor of gna_probe(), but without pci_release_regions(), smatch (v7fcfe259) produces warning: drivers/misc/gna/gna_device.c:78 gna_probe() warn: 'pcidev' not released on lines: 56,65. here's the code refactored: int gna_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id) { struct gna_private *gna_priv; int ret; ret = pcim_enable_device(pcidev); if (ret) { dev_err(&pcidev->dev, "pci device can't be enabled\n"); return ret; } ret = pci_request_regions(pcidev, GNA_DRV_NAME); if (ret) return ret; ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(64)); if (ret) { dev_err(&pcidev->dev, "pci_set_dma_mask returned error %d\n", ret); return ret; } pci_set_master(pcidev); /* init gna device */ gna_priv = devm_kzalloc(&pcidev->dev, sizeof(*gna_priv), GFP_KERNEL); if (!gna_priv) { //pci_release_regions(pcidev); return -ENOMEM; // line 56 } /* Map BAR0 */ gna_priv->bar0.iostart = pci_resource_start(pcidev, 0); gna_priv->bar0.iosize = pci_resource_len(pcidev, 0); gna_priv->bar0.mem_addr = pcim_iomap(pcidev, 0, 0); if (!gna_priv->bar0.mem_addr) { //pci_release_regions(pcidev); dev_err(&pcidev->dev, "could not map BAR 0\n"); return -EINVAL; // line 65 } dev_dbg(&pcidev->dev, "bar0 io start: 0x%llx\n", (unsigned long long)gna_priv->bar0.iostart); dev_dbg(&pcidev->dev, "bar0 io size: %llu\n", (unsigned long long)gna_priv->bar0.iosize); dev_dbg(&pcidev->dev, "bar0 memory address: %p\n", gna_priv->bar0.mem_addr); ret = gna_dev_init(gna_priv, pcidev, pci_id); if (ret) { dev_err(&pcidev->dev, "could not initialize gna private structure\n"); return ret; } return 0; } I've also added 'noinline' directive to pci_release_regions(), to see if it is called by the core code on "rmmod gna", but can't see the call. Is the smatch tool that causes problems here? Do You suggest other way to handle the problem?