Commit f2829d07 authored by Nishad Kamdar's avatar Nishad Kamdar Committed by Greg Kroah-Hartman

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: default avatarNishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6ffcce41
...@@ -350,7 +350,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) ...@@ -350,7 +350,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") { for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
const __be32 *ngpio, *gpiobase; const __be32 *ngpio, *gpiobase;
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
char *name;
if (!of_device_is_available(np)) if (!of_device_is_available(np))
continue; continue;
...@@ -362,9 +361,10 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) ...@@ -362,9 +361,10 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL); range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL);
range->name = name = (char *)&range[1]; if (!range)
sprintf(name, "pio"); return -ENOMEM;
range->name = "pio";
range->npins = __be32_to_cpu(*ngpio); range->npins = __be32_to_cpu(*ngpio);
range->base = __be32_to_cpu(*gpiobase); range->base = __be32_to_cpu(*gpiobase);
range->pin_base = range->base; range->pin_base = range->base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment