Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-02-14 12:09:56 +0100
committerTakashi Iwai <tiwai@suse.de>2019-02-14 12:10:05 +0100
commitbb6ea3e8a1028b4161503df4d31ecb8bdf7797b5 (patch)
tree9d03c5ba1a24a12ce9304b42d8cee10336226d27
parent87496365f21fe91a49ce39e26417c7edcba7d685 (diff)
pinctrl: sx150x: handle failure case of devm_kstrdup
(bsc#1051510).
-rw-r--r--patches.drivers/pinctrl-sx150x-handle-failure-case-of-devm_kstrdup.patch66
-rw-r--r--series.conf1
2 files changed, 67 insertions, 0 deletions
diff --git a/patches.drivers/pinctrl-sx150x-handle-failure-case-of-devm_kstrdup.patch b/patches.drivers/pinctrl-sx150x-handle-failure-case-of-devm_kstrdup.patch
new file mode 100644
index 0000000000..0c5638c045
--- /dev/null
+++ b/patches.drivers/pinctrl-sx150x-handle-failure-case-of-devm_kstrdup.patch
@@ -0,0 +1,66 @@
+From a9d9f6b83f1bb05da849b3540e6d1f70ef1c2343 Mon Sep 17 00:00:00 2001
+From: Nicholas Mc Guire <hofrat@osadl.org>
+Date: Sun, 2 Dec 2018 11:04:17 +0100
+Subject: [PATCH] pinctrl: sx150x: handle failure case of devm_kstrdup
+Git-commit: a9d9f6b83f1bb05da849b3540e6d1f70ef1c2343
+Patch-mainline: v5.0-rc1
+References: bsc#1051510
+
+devm_kstrdup() may return NULL if internal allocation failed.
+Thus using label, name is unsafe without checking. Therefor
+in the unlikely case of allocation failure, sx150x_probe() simply
+returns -ENOMEM.
+
+Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
+Fixes: 9e80f9064e73 ("pinctrl: Add SX150X GPIO Extender Pinctrl Driver")
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pinctrl/pinctrl-sx150x.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
+index cbf58a10113d..4d87d75b9c6e 100644
+--- a/drivers/pinctrl/pinctrl-sx150x.c
++++ b/drivers/pinctrl/pinctrl-sx150x.c
+@@ -1166,7 +1166,6 @@ static int sx150x_probe(struct i2c_client *client,
+ }
+
+ /* Register GPIO controller */
+- pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
+ pctl->gpio.base = -1;
+ pctl->gpio.ngpio = pctl->data->npins;
+ pctl->gpio.get_direction = sx150x_gpio_get_direction;
+@@ -1180,6 +1179,10 @@ static int sx150x_probe(struct i2c_client *client,
+ pctl->gpio.of_node = dev->of_node;
+ #endif
+ pctl->gpio.can_sleep = true;
++ pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
++ if (!pctl->gpio.label)
++ return -ENOMEM;
++
+ /*
+ * Setting multiple pins is not safe when all pins are not
+ * handled by the same regmap register. The oscio pin (present
+@@ -1200,13 +1203,15 @@ static int sx150x_probe(struct i2c_client *client,
+
+ /* Add Interrupt support if an irq is specified */
+ if (client->irq > 0) {
+- pctl->irq_chip.name = devm_kstrdup(dev, client->name,
+- GFP_KERNEL);
+ pctl->irq_chip.irq_mask = sx150x_irq_mask;
+ pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
+ pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
+ pctl->irq_chip.irq_bus_lock = sx150x_irq_bus_lock;
+ pctl->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock;
++ pctl->irq_chip.name = devm_kstrdup(dev, client->name,
++ GFP_KERNEL);
++ if (!pctl->irq_chip.name)
++ return -ENOMEM;
+
+ pctl->irq.masked = ~0;
+ pctl->irq.sense = 0;
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 291f5983b5..f33a022792 100644
--- a/series.conf
+++ b/series.conf
@@ -20123,6 +20123,7 @@
patches.drivers/soc-tegra-Don-t-leak-device-tree-node-reference.patch
patches.drivers/watchdog-w83627hf_wdt-support-Inves.patch
patches.fixes/watchdog-docs-kernel-api-don-t-reference-removed-fun.patch
+ patches.drivers/pinctrl-sx150x-handle-failure-case-of-devm_kstrdup.patch
patches.drivers/pinctrl-sh-pfc-r8a7740-Add-missing-REF125CK-pin-to-g.patch
patches.drivers/pinctrl-sh-pfc-r8a7740-Add-missing-LCD0-marks-to-lcd.patch
patches.drivers/pinctrl-sh-pfc-r8a7791-Remove-bogus-ctrl-marks-from-.patch