stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Keith Busch <keith.busch@intel.com>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 39/75] nvme: fix srcu locking on error return in nvme_get_ns_from_disk
Date: Mon, 17 Jun 2019 23:09:50 +0200	[thread overview]
Message-ID: <20190617210754.286771939@linuxfoundation.org> (raw)
In-Reply-To: <20190617210752.799453599@linuxfoundation.org>

[ Upstream commit 100c815cbd56480b3e31518475b04719c363614a ]

If we can't get a namespace don't leak the SRCU lock.  nvme_ioctl was
working around this, but nvme_pr_command wasn't handling this properly.
Just do what callers would usually expect.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/host/core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index abfb46378cc1..44d8077fbe95 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1277,9 +1277,14 @@ static struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
 {
 #ifdef CONFIG_NVME_MULTIPATH
 	if (disk->fops == &nvme_ns_head_ops) {
+		struct nvme_ns *ns;
+
 		*head = disk->private_data;
 		*srcu_idx = srcu_read_lock(&(*head)->srcu);
-		return nvme_find_path(*head);
+		ns = nvme_find_path(*head);
+		if (!ns)
+			srcu_read_unlock(&(*head)->srcu, *srcu_idx);
+		return ns;
 	}
 #endif
 	*head = NULL;
@@ -1326,9 +1331,9 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 
 	ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
 	if (unlikely(!ns))
-		ret = -EWOULDBLOCK;
-	else
-		ret = nvme_ns_ioctl(ns, cmd, arg);
+		return -EWOULDBLOCK;
+
+	ret = nvme_ns_ioctl(ns, cmd, arg);
 	nvme_put_ns_from_disk(head, srcu_idx);
 	return ret;
 }
-- 
2.20.1




  parent reply	other threads:[~2019-06-17 21:33 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 21:09 [PATCH 4.19 00/75] 4.19.53-stable review Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 01/75] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v3) Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 02/75] nouveau: Fix build with CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT disabled Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 03/75] HID: multitouch: handle faulty Elo touch device Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 04/75] HID: wacom: Dont set tool type until were in range Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 05/75] HID: wacom: Dont report anything prior to the tool entering range Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 06/75] HID: wacom: Send BTN_TOUCH in response to INTUOSP2_BT eraser contact Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 07/75] HID: wacom: Correct button numbering 2nd-gen Intuos Pro over Bluetooth Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 08/75] HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 09/75] Revert "ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops" Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 10/75] ALSA: oxfw: allow PCM capture for Stanton SCS.1m Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 11/75] ALSA: hda/realtek - Update headset mode for ALC256 Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 12/75] ALSA: firewire-motu: fix destruction of data for isochronous resources Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 13/75] libata: Extend quirks for the ST1000LM024 drives with NOLPM quirk Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 14/75] mm/list_lru.c: fix memory leak in __memcg_init_list_lru_node Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 15/75] fs/ocfs2: fix race in ocfs2_dentry_attach_lock() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 16/75] mm/vmscan.c: fix trying to reclaim unevictable LRU page Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 17/75] [PATCH] signal/ptrace: Dont leak unitialized kernel memory with PTRACE_PEEK_SIGINFO Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 18/75] ptrace: restore smp_rmb() in __ptrace_may_access() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 19/75] iommu/arm-smmu: Avoid constant zero in TLBI writes Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 20/75] i2c: acorn: fix i2c warning Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 21/75] bcache: fix stack corruption by PRECEDING_KEY() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 22/75] bcache: only set BCACHE_DEV_WB_RUNNING when cached device attached Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 23/75] cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 24/75] ASoC: cs42xx8: Add regcache mask dirty Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 25/75] ASoC: fsl_asrc: Fix the issue about unsupported rate Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 26/75] drm/i915/sdvo: Implement proper HDMI audio support for SDVO Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 27/75] x86/uaccess, kcov: Disable stack protector Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 28/75] ALSA: seq: Protect in-kernel ioctl calls with mutex Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 29/75] ALSA: seq: Fix race of get-subscription call vs port-delete ioctls Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 30/75] Revert "ALSA: seq: Protect in-kernel ioctl calls with mutex" Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 31/75] s390/kasan: fix strncpy_from_user kasan checks Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 32/75] Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 33/75] f2fs: fix to avoid accessing xattr across the boundary Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 34/75] scsi: qedi: remove memset/memcpy to nfunc and use func instead Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 35/75] scsi: qedi: remove set but not used variables cdev and udev Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 36/75] scsi: lpfc: correct rcu unlock issue in lpfc_nvme_info_show Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 37/75] scsi: lpfc: add check for loss of ndlp when sending RRQ Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 38/75] arm64/mm: Inhibit huge-vmap with ptdump Greg Kroah-Hartman
2019-06-17 21:09 ` Greg Kroah-Hartman [this message]
2019-06-17 21:09 ` [PATCH 4.19 40/75] nvme: remove the ifdef around nvme_nvm_ioctl Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 41/75] nvme: merge nvme_ns_ioctl into nvme_ioctl Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 42/75] nvme: release namespace SRCU protection before performing controller ioctls Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 43/75] nvme: fix memory leak for power latency tolerance Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 44/75] platform/x86: pmc_atom: Add Lex 3I380D industrial PC to critclk_systems DMI table Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 45/75] platform/x86: pmc_atom: Add several Beckhoff Automation boards " Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 46/75] scsi: bnx2fc: fix incorrect cast to u64 on shift operation Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 47/75] libnvdimm: Fix compilation warnings with W=1 Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 48/75] selftests: fib_rule_tests: fix local IPv4 address typo Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 49/75] selftests/timers: Add missing fflush(stdout) calls Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 50/75] tracing: Prevent hist_field_var_ref() from accessing NULL tracing_map_elts Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 51/75] usbnet: ipheth: fix racing condition Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 52/75] KVM: arm/arm64: Move cc/it checks under hyps Makefile to avoid instrumentation Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 53/75] KVM: x86/pmu: mask the result of rdpmc according to the width of the counters Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 54/75] KVM: x86/pmu: do not mask the value that is written to fixed PMUs Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 55/75] KVM: s390: fix memory slot handling for KVM_SET_USER_MEMORY_REGION Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 56/75] tools/kvm_stat: fix fields filter for child events Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 57/75] drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 58/75] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 59/75] usb: dwc2: Fix DMA cache alignment issues Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 60/75] usb: dwc2: host: Fix wMaxPacketSize handling (fix webcam regression) Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 61/75] USB: Fix chipmunk-like voice when using Logitech C270 for recording audio Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 62/75] USB: usb-storage: Add new ID to ums-realtek Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 63/75] USB: serial: pl2303: add Allied Telesis VT-Kit3 Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 64/75] USB: serial: option: add support for Simcom SIM7500/SIM7600 RNDIS mode Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 65/75] USB: serial: option: add Telit 0x1260 and 0x1261 compositions Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 66/75] timekeeping: Repair ktime_get_coarse*() granularity Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 67/75] RAS/CEC: Convert the timer callback to a workqueue Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 68/75] RAS/CEC: Fix binary search function Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 69/75] x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 70/75] x86/kasan: Fix boot with 5-level paging and KASAN Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 71/75] x86/mm/KASLR: Compute the size of the vmemmap section properly Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 72/75] x86/resctrl: Prevent NULL pointer dereference when local MBM is disabled Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 73/75] drm/edid: abstract override/firmware EDID retrieval Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 74/75] drm: add fallback override/firmware EDID modes workaround Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 75/75] rtc: pcf8523: dont return invalid date when battery is low Greg Kroah-Hartman
2019-06-18  2:10 ` [PATCH 4.19 00/75] 4.19.53-stable review kernelci.org bot
2019-06-18  7:44 ` Naresh Kamboju
2019-06-18 13:42 ` shuah
2019-06-18 16:37 ` Guenter Roeck
2019-06-19  8:45 ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190617210754.286771939@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).