linux-uconsole/drivers
Dan Williams ec5471c92f mm, devm_memremap_pages: fix shutdown handling
commit a95c90f1e2 upstream.

The last step before devm_memremap_pages() returns success is to allocate
a release action, devm_memremap_pages_release(), to tear the entire setup
down.  However, the result from devm_add_action() is not checked.

Checking the error from devm_add_action() is not enough.  The api
currently relies on the fact that the percpu_ref it is using is killed by
the time the devm_memremap_pages_release() is run.  Rather than continue
this awkward situation, offload the responsibility of killing the
percpu_ref to devm_memremap_pages_release() directly.  This allows
devm_memremap_pages() to do the right thing relative to init failures and
shutdown.

Without this change we could fail to register the teardown of
devm_memremap_pages().  The likelihood of hitting this failure is tiny as
small memory allocations almost always succeed.  However, the impact of
the failure is large given any future reconfiguration, or disable/enable,
of an nvdimm namespace will fail forever as subsequent calls to
devm_memremap_pages() will fail to setup the pgmap_radix since there will
be stale entries for the physical address range.

An argument could be made to require that the ->kill() operation be set in
the @pgmap arg rather than passed in separately.  However, it helps code
readability, tracking the lifetime of a given instance, to be able to grep
the kill routine directly at the devm_memremap_pages() call site.

Link: http://lkml.kernel.org/r/154275558526.76910.7535251937849268605.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Fixes: e8d5134833 ("memremap: change devm_memremap_pages interface...")
Reviewed-by: "Jérôme Glisse" <jglisse@redhat.com>
Reported-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-13 09:51:04 +01:00
..
accessibility
acpi acpi/nfit: Fix user-initiated ARS to be "ARS-long" rather than "ARS-short" 2018-12-21 14:15:23 +01:00
amba
android binder: fix race that allows malicious free of live buffer 2018-12-05 19:32:11 +01:00
ata libata: whitelist all SAMSUNG MZ7KM* solid-state disks 2018-12-21 14:15:20 +01:00
atm
auxdisplay auxdisplay: charlcd: fix x/y command parsing 2019-01-13 09:51:03 +01:00
base platform-msi: Free descriptors in platform_msi_domain_free() 2019-01-09 17:38:42 +01:00
bcma
block zram: fix double free backing device 2019-01-13 09:51:04 +01:00
bluetooth Bluetooth: hci_qca: Remove hdev dereference in qca_close(). 2018-11-13 11:08:25 -08:00
bus Merge branch 'perm-fix' into omap-for-v4.19/fixes-v2 2018-08-28 09:58:03 -07:00
cdrom cdrom: fix improper type cast, which can leat to information leak. 2018-11-21 09:19:12 +01:00
char tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x 2019-01-09 17:38:49 +01:00
clk clk: sunxi-ng: Use u64 for calculation of NM rate 2019-01-09 17:38:44 +01:00
clocksource clocksource/drivers/arc_timer: Utilize generic sched_clock 2019-01-09 17:38:42 +01:00
connector
cpufreq cpufreq: ti-cpufreq: Only register platform_device when supported 2018-12-13 09:16:13 +01:00
cpuidle ARM: cpuidle: Don't register the driver when back-end init returns -ENXIO 2018-11-21 09:19:23 +01:00
crypto crypto: chcr - small packet Tx stalls the queue 2019-01-09 17:38:44 +01:00
dax mm, devm_memremap_pages: fix shutdown handling 2019-01-13 09:51:04 +01:00
dca
devfreq Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00
dio
dma dmaengine: cppi41: delete channel from pending list when stop channel 2018-12-13 09:16:20 +01:00
dma-buf
edac EDAC, skx_edac: Fix logical channel intermediate decoding 2018-11-13 11:08:44 -08:00
eisa
extcon
firewire firewire: use 64-bit time_t based interfaces 2018-08-17 16:20:27 -07:00
firmware efi/arm: Revert deferred unmap of early memmap mapping 2018-12-01 09:37:33 +01:00
fmc
fpga fpga: bridge: fix obvious function documentation error 2018-09-30 08:49:55 -07:00
fsi fsi: master-ast-cf: select GENERIC_ALLOCATOR 2018-12-17 09:24:35 +01:00
gnss gnss: sirf: fix activation retry handling 2018-12-13 09:16:22 +01:00
gpio gpio: mvebu: only fail on missing clk if pwm is actually to be used 2019-01-13 09:51:03 +01:00
gpu drm/amdgpu: Fix DEBUG_LOCKS_WARN_ON(depth <= 0) in amdgpu_ctx.lock 2019-01-13 09:50:57 +01:00
hid HID: ite: Add USB id match for another ITE based keyboard rfkill key quirk 2019-01-13 09:50:56 +01:00
hsi
hv x86, hyperv: remove PCI dependency 2019-01-13 09:51:00 +01:00
hwmon hwmon: (w83795) temp4_type has writable permission 2018-12-17 09:24:33 +01:00
hwspinlock hwspinlock: Fix incorrect return pointers 2018-07-30 20:54:51 -07:00
hwtracing coresight: etb10: Fix handling of perf mode 2018-11-13 11:08:36 -08:00
i2c i2c: uniphier-f: fix violation of tLOW requirement for Fast-mode 2018-12-21 14:15:24 +01:00
ide ide: pmac: add of_node_put() 2018-12-21 14:15:18 +01:00
idle
iio iio:st_magn: Fix enable device after trigger 2018-12-05 19:32:13 +01:00
infiniband IB/core: Fix oops in netdev_next_upper_dev_rcu() 2019-01-13 09:50:57 +01:00
input Input: synaptics - enable SMBus for HP EliteBook 840 G4 2019-01-13 09:51:03 +01:00
iommu iommu/arm-smmu-v3: Fix big-endian CMD_SYNC writes 2019-01-09 17:38:49 +01:00
ipack
irqchip irqchip/pdc: Setup all edge interrupts as rising edge at GIC 2018-11-13 11:08:34 -08:00
isdn isdn: fix kernel-infoleak in capi_unlocked_ioctl 2019-01-09 17:38:31 +01:00
leds leds: ns2: Change unsigned to unsigned int 2018-08-06 23:03:12 +02:00
lightnvm lightnvm: pblk: fix race condition on metadata I/O 2018-11-13 11:08:21 -08:00
macintosh macintosh: therm_windtunnel: drop using attach_adapter 2018-08-24 14:42:42 +02:00
mailbox mailbox: PCC: handle parse error 2018-11-13 11:08:18 -08:00
mcb
md dm zoned: Fix target BIO completion handling 2018-12-19 19:19:53 +01:00
media media: v4l2-tpg: array index could become negative 2019-01-09 17:38:47 +01:00
memory memory: ti-aemif: fix a potential NULL-pointer dereference 2018-09-06 10:04:07 -07:00
memstick
message scsi: message: fusion: Replace GFP_ATOMIC with GFP_KERNEL 2018-07-30 23:17:53 -04:00
mfd Revert "mfd: cros_ec: Use devm_kzalloc for private data" 2018-12-13 09:16:17 +01:00
misc ocxl: Fix endiannes bug in read_afu_name() 2019-01-09 17:38:43 +01:00
mmc mmc: omap_hsmmc: fix DMA API warning 2018-12-29 13:37:56 +01:00
mtd mtd: rawnand: omap2: Pass the parent of pdev to dma_request_chan() 2019-01-09 17:38:37 +01:00
mux mux: adgs1408: use the correct MODULE_LICENSE 2018-10-12 17:36:39 +02:00
net qmi_wwan: Fix qmap header retrieval in qmimux_rx_fixup 2019-01-13 09:51:03 +01:00
nfc NFC: nfcmrvl_uart: fix OF child-node lookup 2018-11-13 11:08:48 -08:00
ntb
nubus
nvdimm mm, devm_memremap_pages: fix shutdown handling 2019-01-13 09:51:04 +01:00
nvme nvmet-rdma: fix response use after free 2018-12-21 14:15:25 +01:00
nvmem nvmem: check the return value of nvmem_add_cells() 2018-11-13 11:08:35 -08:00
of of/device: Really only set bus DMA mask when appropriate 2018-11-27 16:13:05 +01:00
opp opp: ti-opp-supply: Correct the supply in _get_optimal_vdd_voltage call 2018-12-01 09:37:27 +01:00
oprofile
parisc
parport Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00
pci PCI: imx6: Fix link training status detection in link up check 2018-12-17 09:24:33 +01:00
pcmcia pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges 2018-11-13 11:08:17 -08:00
perf arm64: perf: Reject stand-alone CHAIN events for PMUv3 2018-10-12 15:25:17 +01:00
phy phy: qcom-qusb2: Fix HSTX_TRIM tuning with fused value for SDM845 2018-12-17 09:24:34 +01:00
pinctrl pinctrl: meson: fix pull enable register calculation 2019-01-13 09:50:54 +01:00
platform platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307 2018-11-27 16:13:00 +01:00
pnp
power power: supply: twl4030-charger: fix OF sibling-node lookup 2018-11-13 11:08:51 -08:00
powercap
pps
ps3
ptp ptp: fix Spectre v1 vulnerability 2018-10-17 22:00:22 -07:00
pwm pwm: mediatek: Add MT7628 support 2018-08-20 11:36:07 +02:00
rapidio drivers/rapidio/devices/rio_mport_cdev.c: remove redundant pointer md 2018-08-22 10:52:51 -07:00
ras
regulator regulator: fix crash caused by null driver data 2018-09-20 09:04:51 -07:00
remoteproc remoteproc: qcom: q6v5: Propagate EPROBE_DEFER 2018-11-13 11:08:52 -08:00
reset ARM: SoC: late updates 2018-08-25 14:12:36 -07:00
rpmsg rpmsg: smd: fix memory leak on channel create 2018-11-13 11:08:55 -08:00
rtc rtc: m41t80: Correct alarm month range with RTC reads 2019-01-09 17:38:48 +01:00
s390 scsi: zfcp: fix posting too many status read buffers leading to adapter shutdown 2019-01-13 09:51:03 +01:00
sbus drivers/sbus/char: add of_node_put() 2018-12-21 14:15:17 +01:00
scsi scsi: lpfc: do not set queue->page_count to 0 if pc_sli4_params.wqpcnt is invalid 2019-01-13 09:51:03 +01:00
sfi
sh sh: introduce a sh_cacheop_vaddr helper 2018-08-02 13:54:06 +02:00
siox
slimbus slimbus: ngd: mark PM functions as __maybe_unused 2018-12-19 19:19:49 +01:00
sn
soc soc: ti: QMSS: Fix usage of irq_set_affinity_hint 2018-11-21 09:19:18 +01:00
soundwire soundwire: Fix acquiring bus lock twice during master release 2018-08-27 09:49:48 +05:30
spi spi: bcm2835: Unbreak the build of esoteric configs 2019-01-09 17:38:49 +01:00
spmi
ssb ssb: Remove SSB_WARN_ON, SSB_BUG_ON and SSB_DEBUG 2018-08-09 18:47:47 +03:00
staging staging: wilc1000: fix missing read_write setting when reading data 2019-01-09 17:38:40 +01:00
target scsi: target: iscsi: cxgbit: add missing spin_lock_init() 2019-01-13 09:50:59 +01:00
tc TC: Set DMA masks for devices 2018-11-13 11:08:51 -08:00
tee ARM: SoC driver updates 2018-08-23 13:52:46 -07:00
thermal thermal: armada: fix legacy validity test sense 2018-12-21 14:15:22 +01:00
thunderbolt thunderbolt: Prevent root port runtime suspend during NVM upgrade 2018-12-17 09:24:36 +01:00
tty serial/sunsu: fix refcount leak 2019-01-13 09:51:03 +01:00
uio uio: Fix an Oops on load 2018-11-27 16:13:09 +01:00
usb cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader. 2019-01-09 17:38:45 +01:00
uwb
vfio powerpc updates for 4.19 2018-08-17 11:32:50 -07:00
vhost vhost: make sure used idx is seen before log in vhost_add_used_n() 2019-01-09 17:38:34 +01:00
video mach64: fix image corruption due to reading accelerator registers 2018-11-21 09:19:17 +01:00
virt
virtio virtio, vhost: fixes, tweaks 2018-08-24 08:45:19 -07:00
visorbus
vlynq
vme
w1 w1: omap-hdq: fix missing bus unregister at removal 2018-11-13 11:08:48 -08:00
watchdog include/linux/compiler*.h: make compiler-*.h mutually exclusive 2018-08-22 17:31:34 -07:00
xen pvcalls-front: fixes incorrect error handling 2018-12-17 09:24:39 +01:00
zorro
Kconfig
Makefile Char/Misc driver patches for 4.19-rc1 2018-08-18 11:04:51 -07:00