linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kangjie Lu <kjlu@umn.edu>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-leds@vger.kernel.org
Subject: [PATCH AUTOSEL 5.0 97/98] leds: pca9532: fix a potential NULL pointer dereference
Date: Mon, 22 Apr 2019 15:42:04 -0400	[thread overview]
Message-ID: <20190422194205.10404-97-sashal@kernel.org> (raw)
In-Reply-To: <20190422194205.10404-1-sashal@kernel.org>

From: Kangjie Lu <kjlu@umn.edu>

[ Upstream commit 0aab8e4df4702b31314a27ec4b0631dfad0fae0a ]

In case of_match_device cannot find a match, return -EINVAL to avoid
NULL pointer dereference.

Fixes: fa4191a609f2 ("leds: pca9532: Add device tree support")
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
 drivers/leds/leds-pca9532.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 7fea18b0c15d..7cb4d685a1f1 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -513,6 +513,7 @@ static int pca9532_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
 {
 	int devid;
+	const struct of_device_id *of_id;
 	struct pca9532_data *data = i2c_get_clientdata(client);
 	struct pca9532_platform_data *pca9532_pdata =
 			dev_get_platdata(&client->dev);
@@ -528,8 +529,11 @@ static int pca9532_probe(struct i2c_client *client,
 			dev_err(&client->dev, "no platform data\n");
 			return -EINVAL;
 		}
-		devid = (int)(uintptr_t)of_match_device(
-			of_pca9532_leds_match, &client->dev)->data;
+		of_id = of_match_device(of_pca9532_leds_match,
+				&client->dev);
+		if (unlikely(!of_id))
+			return -EINVAL;
+		devid = (int)(uintptr_t) of_id->data;
 	} else {
 		devid = id->driver_data;
 	}
-- 
2.19.1


  parent reply	other threads:[~2019-04-22 19:45 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 19:40 [PATCH AUTOSEL 5.0 01/98] arm64: dts: renesas: r8a77990: Fix SCIF5 DMA channels Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 02/98] ARM: dts: bcm283x: Fix hdmi hpd gpio pull Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 03/98] s390: limit brk randomization to 32MB Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 04/98] mt76x02: fix hdr pointer in write txwi for USB Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 05/98] mt76: mt76x2: fix external LNA gain settings Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 06/98] mt76: mt76x2: fix 2.4 GHz channel " Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 07/98] net: ieee802154: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 08/98] ieee802154: hwsim: propagate genlmsg_reply return code Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 09/98] Btrfs: fix file corruption after snapshotting due to mix of buffered/DIO writes Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 10/98] net: stmmac: don't set own bit too early for jumbo frames Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 11/98] net: stmmac: fix jumbo frame sending with non-linear skbs Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 12/98] qlcnic: Avoid potential NULL pointer dereference Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 13/98] xsk: fix umem memory leak on cleanup Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 14/98] staging: axis-fifo: add CONFIG_OF dependency Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 15/98] staging, mt7621-pci: fix build without pci support Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 16/98] netfilter: nft_set_rbtree: check for inactive element after flag mismatch Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 17/98] netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 18/98] netfilter: fix NETFILTER_XT_TARGET_TEE dependencies Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 19/98] netfilter: ip6t_srh: fix NULL pointer dereferences Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 20/98] netfilter: nf_tables: bogus EBUSY in helper removal from transaction Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 21/98] s390/qeth: fix race when initializing the IP address table Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 22/98] ARM: imx51: fix a leaked reference by adding missing of_node_put Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 23/98] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init() Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 24/98] serial: ar933x_uart: Fix build failure with disabled console Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 25/98] KVM: arm64: Reset the PMU in preemptible context Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 26/98] arm64: KVM: Always set ICH_HCR_EL2.EN if GICv4 is enabled Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 27/98] KVM: arm/arm64: vgic-its: Take the srcu lock when writing to guest memory Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 28/98] KVM: arm/arm64: vgic-its: Take the srcu lock when parsing the memslots Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 29/98] KVM: arm/arm64: Enforce PTE mappings at stage2 when needed Sasha Levin
2019-04-23  9:27   ` Suzuki K Poulose
2019-05-02 12:50     ` Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 30/98] usb: dwc3: pci: add support for Comet Lake PCH ID Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 31/98] usb: gadget: net2280: Fix overrun of OUT messages Sasha Levin
2019-04-22 19:40 ` [PATCH AUTOSEL 5.0 32/98] usb: gadget: net2280: Fix net2280_dequeue() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 33/98] usb: gadget: net2272: Fix net2272_dequeue() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 34/98] ARM: dts: pfla02: increase phy reset duration Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 35/98] i2c: i801: Add support for Intel Comet Lake Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 36/98] KVM: arm/arm64: Fix handling of stage2 huge mappings Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 37/98] net: ks8851: Dequeue RX packets explicitly Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 38/98] net: ks8851: Reassert reset pin if chip ID check fails Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 39/98] net: ks8851: Delay requesting IRQ until opened Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 40/98] net: ks8851: Set initial carrier state to down Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 41/98] staging: rtl8188eu: Fix potential NULL pointer dereference of kcalloc Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 42/98] staging: rtlwifi: rtl8822b: fix to avoid potential NULL pointer dereference Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 43/98] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 44/98] staging: rtlwifi: Fix potential NULL pointer dereference of kzalloc Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 45/98] net: phy: Add DP83825I to the DP83822 driver Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 46/98] net: macb: Add null check for PCLK and HCLK Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 47/98] net/sched: don't dereference a->goto_chain to read the chain index Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 48/98] ARM: dts: imx6qdl: Fix typo in imx6qdl-icore-rqs.dtsi Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 49/98] drm/tegra: hub: Fix dereference before check Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 50/98] NFS: Fix a typo in nfs_init_timeout_values() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 51/98] net: xilinx: fix possible object reference leak Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 52/98] net: ibm: " Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 53/98] net: ethernet: ti: " Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 54/98] drm: Fix drm_release() and device unplug Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 55/98] gpio: aspeed: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 56/98] drm/meson: Fix invalid pointer in meson_drv_unbind() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 57/98] drm/meson: Uninstall IRQ handler Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 58/98] ARM: davinci: fix build failure with allnoconfig Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 59/98] sbitmap: order READ/WRITE freed instance and setting clear bit Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 60/98] staging: vc04_services: Fix an error code in vchiq_probe() Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 61/98] libceph: fix breakage caused by multipage bvecs Sasha Levin
2019-04-23  8:28   ` Ilya Dryomov
2019-05-02 12:51     ` Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 62/98] scsi: mpt3sas: Fix kernel panic during expander reset Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 63/98] scsi: aacraid: Insure we don't access PCIe space during AER/EEH Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 64/98] scsi: qla4xxx: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 65/98] usb: usb251xb: fix to avoid " Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 66/98] leds: trigger: netdev: fix refcnt leak on interface rename Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 67/98] SUNRPC: fix uninitialized variable warning Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 68/98] x86/realmode: Don't leak the trampoline kernel address Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 69/98] usb: u132-hcd: fix resource leak Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 70/98] tty: fix NULL pointer issue when tty_port ops is not set Sasha Levin
2019-04-22 20:40   ` Greg Kroah-Hartman
2019-05-02 12:53     ` Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 71/98] ceph: fix use-after-free on symlink traversal Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 72/98] scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 73/98] x86/mm: Don't exceed the valid physical address space Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 74/98] libata: fix using DMA buffers on stack Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 75/98] kbuild: skip parsing pre sub-make code for recursion Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 76/98] afs: Fix StoreData op marshalling Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 77/98] gpio: of: Check propname before applying "cs-gpios" quirks Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 78/98] gpio: of: Check for "spi-cs-high" in child instead of parent node Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 79/98] KVM: nVMX: Do not inherit quadrant and invalid for the root shadow EPT Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 80/98] KVM: SVM: Workaround errata#1096 (insn_len maybe zero on SMAP violation) Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 81/98] kvm/x86: Move MSR_IA32_ARCH_CAPABILITIES to array emulated_msrs Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 82/98] x86/kvm/hyper-v: avoid spurious pending stimer on vCPU init Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 83/98] KVM: selftests: assert on exit reason in CR4/cpuid sync test Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 84/98] KVM: selftests: explicitly disable PIE for tests Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 85/98] KVM: selftests: disable stack protector for all KVM tests Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 86/98] KVM: selftests: complete IO before migrating guest state Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 87/98] gpio: of: Fix of_gpiochip_add() error path Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 88/98] nvme-multipath: relax ANA state check Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 89/98] nvmet: fix building bvec from sg list Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 90/98] nvmet: fix error flow during ns enable Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 91/98] perf cs-etm: Add missing case value Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 92/98] perf machine: Update kernel map address and re-order properly Sasha Levin
2019-04-22 19:42 ` [PATCH AUTOSEL 5.0 93/98] kconfig/[mn]conf: handle backspace (^H) key Sasha Levin
2019-04-22 19:42 ` [PATCH AUTOSEL 5.0 94/98] iommu/amd: Reserve exclusion range in iova-domain Sasha Levin
2019-04-22 19:42 ` [PATCH AUTOSEL 5.0 95/98] kasan: fix variable 'tag' set but not used warning Sasha Levin
2019-04-22 19:42 ` [PATCH AUTOSEL 5.0 96/98] ptrace: take into account saved_sigmask in PTRACE{GET,SET}SIGMASK Sasha Levin
2019-04-22 19:42 ` Sasha Levin [this message]
2019-04-22 19:42 ` [PATCH AUTOSEL 5.0 98/98] leds: trigger: netdev: use memcpy in device_name_store Sasha Levin

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=20190422194205.10404-97-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.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).