summaryrefslogtreecommitdiff
path: root/drivers/staging/mt7621-pinctrl
diff options
context:
space:
mode:
authorNishad Kamdar <nishadkamdar@gmail.com>2019-01-29 21:15:12 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-30 15:38:50 +0100
commitf2829d070f3da88a500f257013f387c5dc7617db (patch)
treeb4df32927e9926be85f552fe854bbd01ffb478bd /drivers/staging/mt7621-pinctrl
parent6ffcce41782749038cd34e1724dff7d055606967 (diff)
staging: mt7621-pinctrl: Test devm_kzalloc for failure while improving the code
This patch tests the return of devm_kzalloc for failure and improves the code. Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/mt7621-pinctrl')
-rw-r--r--drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index 3e959fa73703..9b52d44abef1 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -350,7 +350,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
const __be32 *ngpio, *gpiobase;
struct pinctrl_gpio_range *range;
- char *name;
if (!of_device_is_available(np))
continue;
@@ -362,9 +361,10 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
return -EINVAL;
}
- range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
- range->name = name = (char *)&range[1];
- sprintf(name, "pio");
+ range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL);
+ if (!range)
+ return -ENOMEM;
+ range->name = "pio";
range->npins = __be32_to_cpu(*ngpio);
range->base = __be32_to_cpu(*gpiobase);
range->pin_base = range->base;