android_kernel_oneplus_msm8998/drivers
Rhyland Klein acbda596b5 power_supply: power_supply_read_temp only if use_cnt > 0
commit 5bc28b93a36e3cb3acc2870fb75cb6ffb182fece upstream.

Change power_supply_read_temp() to use power_supply_get_property()
so that it will check the use_cnt and ensure it is > 0. The use_cnt
will be incremented at the end of __power_supply_register, so this
will block to case where get_property can be called before the supply
is fully registered. This fixes the issue show in the stack below:

[    1.452598] power_supply_read_temp+0x78/0x80
[    1.458680] thermal_zone_get_temp+0x5c/0x11c
[    1.464765] thermal_zone_device_update+0x34/0xb4
[    1.471195] thermal_zone_device_register+0x87c/0x8cc
[    1.477974] __power_supply_register+0x364/0x424
[    1.484317] power_supply_register_no_ws+0x10/0x18
[    1.490833] bq27xxx_battery_setup+0x10c/0x164
[    1.497003] bq27xxx_battery_i2c_probe+0xd0/0x1b0
[    1.503435] i2c_device_probe+0x174/0x240
[    1.509172] driver_probe_device+0x1fc/0x29c
[    1.515167] __driver_attach+0xa4/0xa8
[    1.520643] bus_for_each_dev+0x58/0x98
[    1.526204] driver_attach+0x20/0x28
[    1.531505] bus_add_driver+0x1c8/0x22c
[    1.537067] driver_register+0x68/0x108
[    1.542630] i2c_register_driver+0x38/0x7c
[    1.548457] bq27xxx_battery_i2c_driver_init+0x18/0x20
[    1.555321] do_one_initcall+0x38/0x12c
[    1.560886] kernel_init_freeable+0x148/0x1ec
[    1.566972] kernel_init+0x10/0xfc
[    1.572101] ret_from_fork+0x10/0x40

Also make the same change to ps_get_max_charge_cntl_limit() and
ps_get_cur_chrage_cntl_limit() to be safe. Lastly, change the return
value of power_supply_get_property() to -EAGAIN from -ENODEV if
use_cnt <= 0.

Fixes: 297d716f62 ("power_supply: Change ownership from driver to core")
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-10 11:49:27 +02:00
..
accessibility
acpi ACPI / osi: Fix an issue that acpi_osi=!* cannot disable ACPICA internal strings 2016-06-01 12:15:50 -07:00
amba
android drivers: android: correct the size of struct binder_uintptr_t for BC_DEAD_BINDER_DONE 2016-03-03 15:07:10 -08:00
ata scsi: fix race between simultaneous decrements of ->host_failed 2016-07-27 09:47:39 -07:00
atm
auxdisplay
base base: make module_create_drivers_dir race-free 2016-07-27 09:47:32 -07:00
bcma x86/quirks: Add early quirk to reset Apple AirPort card 2016-08-10 11:49:24 +02:00
block nbd: ratelimit error msgs after socket close 2016-05-11 11:21:10 +02:00
bluetooth Bluetooth: vhci: Fix race at creating hci device 2016-06-01 12:15:50 -07:00
bus bus: imx-weim: Take the 'status' property value into account 2016-05-04 14:48:54 -07:00
cdrom
char ipmi: Remove smi_msg from waiting_rcv_msgs list before handle_one_recv_msg() 2016-07-27 09:47:32 -07:00
clk clk: bcm2835: divider value has to be 1 or more 2016-06-07 18:14:35 -07:00
clocksource clockevents/tcb_clksrc: Prevent disabling an already disabled clock 2016-03-03 15:07:15 -08:00
connector connector: bump skb->users before callback invocation 2016-01-04 21:46:45 -05:00
cpufreq cpufreq: intel_pstate: Fix processing for turbo activation ratio 2016-05-04 14:48:44 -07:00
cpuidle cpuidle: Fix cpuidle_state_is_coupled() argument in cpuidle_enter() 2016-06-07 18:14:34 -07:00
crypto crypto: qat - make qat_asym_algs.o depend on asn1 headers 2016-07-27 09:47:40 -07:00
dca
devfreq
dio
dma dmaengine: at_xdmac: double FIFO flush needed to compute residue 2016-08-10 11:49:25 +02:00
dma-buf
edac EDAC, sb_edac: Fix rank lookup on Broadwell 2016-07-27 09:47:27 -07:00
eisa
extcon extcon: max77843: Use correct size for reading the interrupt register 2016-05-04 14:48:54 -07:00
firewire
firmware efi: Expose non-blocking set_variable() wrapper to efivars 2016-05-04 14:48:49 -07:00
fmc
fpga fpga manager: Fix firmware resource leak on error 2015-11-24 15:25:46 -08:00
gpio Revert "gpiolib: Split GPIO flags parsing and GPIO configuration" 2016-07-27 09:47:29 -07:00
gpu drm/i915: Revert DisplayPort fast link training feature 2016-07-27 09:47:40 -07:00
hid HID: multitouch: enable palm rejection for Windows Precision Touchpad 2016-07-27 09:47:32 -07:00
hsi
hv Drivers: hv: vmbus: Fix a Host signaling bug 2016-03-03 15:07:16 -08:00
hwmon hwmon: (dell-smm) Cache fan_type() calls and change fan detection 2016-07-27 09:47:37 -07:00
hwspinlock drivers/hwspinlock: fix race between radix tree insertion and lookup 2016-02-25 12:01:23 -08:00
hwtracing stm class: Select CONFIG_SRCU 2016-05-04 14:48:54 -07:00
i2c i2c: exynos5: Fix possible ABBA deadlock by keeping I2C clock prepared 2016-05-04 14:48:47 -07:00
ide
idle intel_idle: prevent SKL-H boot failure when C8+C9+C10 enabled 2016-04-12 09:09:05 -07:00
iio iio:ad7266: Fix probe deferral for vref 2016-07-27 09:47:37 -07:00
infiniband IB/mlx4: Properly initialize GRH TClass and FlowLabel in AHs 2016-07-27 09:47:27 -07:00
input Input: tsc200x - report proper input_dev name 2016-08-10 11:49:26 +02:00
iommu iommu/amd: Fix unity mapping initialization race 2016-07-27 09:47:32 -07:00
ipack
irqchip irqchip/gic-v3: Configure all interrupts as non-secure Group-1 2016-06-01 12:15:49 -07:00
isdn ser_gigaset: remove unnecessary kfree() calls from release method 2015-12-15 13:24:21 -05:00
leds
lguest
lightnvm lightnvm: wrong offset in bad blk lun calculation 2015-12-29 08:28:32 -07:00
macintosh
mailbox
mcb mcb: Fixed bar number assignment for the gdd 2016-06-01 12:15:53 -07:00
md MD: make bio mergeable 2016-05-11 11:21:13 +02:00
media uvc: Forward compat ioctls to their handlers directly 2016-07-27 09:47:29 -07:00
memory memory: omap-gpmc: Fix omap gpmc EXTRADELAY timing 2016-07-27 09:47:35 -07:00
memstick
message
mfd mfd: intel_soc_pmic_core: Terminate panel control GPIO lookup table correctly 2016-06-07 18:14:34 -07:00
misc mei: bus: call mei_cl_read_start under device lock 2016-06-01 12:15:50 -07:00
mmc mmc: sdhci-pci: Remove MMC_CAP_BUS_WIDTH_TEST for Intel controllers 2016-06-01 12:15:50 -07:00
mtd ubi: Make recover_peb power cut aware 2016-07-27 09:47:33 -07:00
net cdc_ncm: workaround for EM7455 "silent" data interface 2016-07-27 09:47:31 -07:00
nfc
ntb
nubus
nvdimm libnvdimm, pfn: fix uuid validation 2016-04-20 15:41:54 +09:00
nvme NVMe: IO ending fixes on surprise removal 2015-12-22 10:12:04 -07:00
nvmem nvmem: mxs-ocotp: fix buffer overflow in read 2016-05-11 11:21:21 +02:00
of of: irq: fix of_irq_get[_byname]() kernel-doc 2016-07-27 09:47:29 -07:00
oprofile
parisc parisc iommu: fix panic due to trying to allocate too large region 2015-12-12 16:07:25 +01:00
parport
pci PCI: Disable all BAR sizing for devices with non-compliant BARs 2016-06-07 18:14:35 -07:00
pcmcia pcmcia: db1xxx_ss: fix last irq_to_gpio user 2016-04-20 15:42:09 +09:00
perf
phy phy: core: fix wrong err handle for phy_power_on 2016-03-03 15:07:28 -08:00
pinctrl pinctrl: imx: Do not treat a PIN without MUX register as an error 2016-08-10 11:49:27 +02:00
platform dell-rbtn: Ignore ACPI notifications if device is suspended 2016-06-01 12:15:50 -07:00
pnp
power power_supply: power_supply_read_temp only if use_cnt > 0 2016-08-10 11:49:27 +02:00
powercap powercap / RAPL: fix BIOS lock check 2015-12-12 02:31:11 +01:00
pps pps: do not crash when failed to register 2016-08-10 11:49:25 +02:00
ps3
ptp
pwm pwm: brcmstb: Fix check of devm_ioremap_resource() return code 2016-05-04 14:48:47 -07:00
rapidio
ras
regulator regulator: axp20x: Fix axp22x ldo_io voltage ranges 2016-05-18 17:06:51 -07:00
remoteproc remoteproc: fix memory leak of remoteproc ida cache layers 2015-11-26 17:44:28 +02:00
reset
rpmsg
rtc rtc: max77686: Properly handle regmap_irq_get_virq() error code 2016-05-04 14:48:52 -07:00
s390 s390/dasd: fix diag 0x250 inline assembly 2016-03-16 08:42:58 -07:00
sbus
scsi 53c700: fix BUG on untagged commands 2016-07-27 09:47:39 -07:00
sfi
sh drivers: sh: Restore legacy clock domain on SuperH platforms 2016-03-09 15:34:49 -08:00
sn
soc soc: rockchip: power-domain: fix err handle while probing 2016-05-11 11:21:11 +02:00
spi spi: spi-ti-qspi: Handle truncated frames properly 2016-05-18 17:06:47 -07:00
spmi
ssb
staging staging: iio: accel: fix error check 2016-07-27 09:47:36 -07:00
target target: Fix target_release_cmd_kref shutdown comp leak 2016-04-12 09:09:02 -07:00
tc
thermal thermal: cpu_cooling: fix improper order during initialization 2016-07-27 09:47:29 -07:00
thunderbolt thunderbolt: Fix double free of drom buffer 2016-06-01 12:15:53 -07:00
tty tty/vt/keyboard: fix OOB access in do_compute_shiftstate() 2016-07-27 09:47:37 -07:00
uio
usb USB: OHCI: Don't mark EDs as ED_OPER if scheduling fails 2016-08-10 11:49:24 +02:00
uwb
vfio vfio: fix ioctl error handling 2016-03-09 15:34:50 -08:00
vhost vhost: replace % with & on data path 2015-12-07 17:28:10 +02:00
video fbdev: da8xx-fb: fix videomodes of lcd panels 2016-05-04 14:48:51 -07:00
virt
virtio virtio_balloon: fix PFN format for virtio-1 2016-07-27 09:47:34 -07:00
vlynq
vme
w1
watchdog watchdog: rc32434_wdt: fix ioctl error handling 2016-04-12 09:08:54 -07:00
xen xenbus: don't bail early from xenbus_dev_request_and_reply() 2016-08-10 11:49:26 +02:00
zorro
Kconfig
Makefile null_blk: register as a LightNVM device 2015-11-16 15:22:28 -07:00