[linux-nvme:nvme-6.5 15/21] drivers/nvme/host/fabrics.c:96:2-8: preceding lock on line 85 (fwd)
Chaitanya Kulkarni
chaitanyak at nvidia.com
Thu Jun 1 22:07:25 PDT 2023
On 6/1/23 21:55, Julia Lawall wrote:
> An unlock appears to be missing on line 96.
>
> julia
>
> ---------- Forwarded message ----------
> Date: Fri, 2 Jun 2023 09:57:07 +0800
> From: kernel test robot <lkp at intel.com>
> To: oe-kbuild at lists.linux.dev
> Cc: lkp at intel.com, Julia Lawall <julia.lawall at inria.fr>
> Subject: [linux-nvme:nvme-6.5 15/21] drivers/nvme/host/fabrics.c:96:2-8:
> preceding lock on line 85
>
> BCC: lkp at intel.com
> CC: oe-kbuild-all at lists.linux.dev
> CC: linux-nvme at lists.infradead.org
> TO: Max Gurtovoy <mgurtovoy at nvidia.com>
> CC: Keith Busch <kbusch at kernel.org>
> CC: Israel Rukshin <israelr at nvidia.com>
> CC: Christoph Hellwig <hch at lst.de>
>
> tree: git://git.infradead.org/nvme.git nvme-6.5
> head: 14ad91f7a9a29562f23bedd205ef209255d8b8d1
> commit: f0cebf82004d610be3ef47abf315ddf95aa2dcd1 [15/21] nvme-fabrics: prevent overriding of existing host
> :::::: branch date: 9 hours ago
> :::::: commit date: 3 weeks ago
> config: riscv-randconfig-c032-20230531 (https://download.01.org/0day-ci/archive/20230602/202306020909.MTUEBeIa-lkp@intel.com/config)
> compiler: riscv64-linux-gcc (GCC) 12.3.0
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp at intel.com>
> | Reported-by: Julia Lawall <julia.lawall at inria.fr>
> | Closes: https://lore.kernel.org/r/202306020909.MTUEBeIa-lkp@intel.com/
>
> cocci warnings: (new ones prefixed by >>)
>>> drivers/nvme/host/fabrics.c:96:2-8: preceding lock on line 85
> vim +96 drivers/nvme/host/fabrics.c
>
> f0cebf82004d61 Max Gurtovoy 2023-05-12 80
> f0cebf82004d61 Max Gurtovoy 2023-05-12 81 static struct nvmf_host *nvmf_host_add(const char *hostnqn, uuid_t *id)
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 82 {
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 83 struct nvmf_host *host;
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 84
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 @85 mutex_lock(&nvmf_hosts_mutex);
> f0cebf82004d61 Max Gurtovoy 2023-05-12 86 host = __nvmf_host_find(hostnqn, id);
> f0cebf82004d61 Max Gurtovoy 2023-05-12 87 if (IS_ERR(host)) {
> f0cebf82004d61 Max Gurtovoy 2023-05-12 88 goto out_unlock;
> f0cebf82004d61 Max Gurtovoy 2023-05-12 89 } else if (host) {
> 98096d8a787f05 Christoph Hellwig 2016-08-18 90 kref_get(&host->ref);
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 91 goto out_unlock;
> 98096d8a787f05 Christoph Hellwig 2016-08-18 92 }
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 93
> f0cebf82004d61 Max Gurtovoy 2023-05-12 94 host = nvmf_host_alloc(hostnqn, id);
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 95 if (!host)
> f0cebf82004d61 Max Gurtovoy 2023-05-12 @96 return ERR_PTR(-ENOMEM);
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 97
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 98 list_add_tail(&host->list, &nvmf_hosts);
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 99 out_unlock:
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 100 mutex_unlock(&nvmf_hosts_mutex);
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 101 return host;
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 102 }
> 07bfcd09a28855 Christoph Hellwig 2016-06-13 103
>
can you see if following fixes the issue ?
I'll send a patch soon:-
nvme (nvme-6.5) # git diff
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index b1fa27b60917..91c3d7c1fa3e 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -92,8 +92,10 @@ static struct nvmf_host *nvmf_host_add(const char
*hostnqn, uuid_t *id)
}
host = nvmf_host_alloc(hostnqn, id);
- if (!host)
+ if (!host) {
+ mutex_unlock(&nvmf_hosts_mutex);
return ERR_PTR(-ENOMEM);
+ }
list_add_tail(&host->list, &nvmf_hosts);
out_unlock:
-ck
More information about the Linux-nvme
mailing list