| .. | .. |
|---|
| 220 | 220 | /* allocate our function and group mapping index buffers */ |
|---|
| 221 | 221 | f = p->func = devm_kcalloc(p->dev, |
|---|
| 222 | 222 | p->func_count, |
|---|
| 223 | | - sizeof(struct rt2880_pmx_func), |
|---|
| 223 | + sizeof(*p->func), |
|---|
| 224 | 224 | GFP_KERNEL); |
|---|
| 225 | 225 | gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int), |
|---|
| 226 | 226 | GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 267 | 267 | p->func[i]->pin_count, |
|---|
| 268 | 268 | sizeof(int), |
|---|
| 269 | 269 | GFP_KERNEL); |
|---|
| 270 | + if (!p->func[i]->pins) |
|---|
| 271 | + return -ENOMEM; |
|---|
| 270 | 272 | for (j = 0; j < p->func[i]->pin_count; j++) |
|---|
| 271 | 273 | p->func[i]->pins[j] = p->func[i]->pin_first + j; |
|---|
| 272 | 274 | |
|---|
| .. | .. |
|---|
| 350 | 352 | for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") { |
|---|
| 351 | 353 | const __be32 *ngpio, *gpiobase; |
|---|
| 352 | 354 | struct pinctrl_gpio_range *range; |
|---|
| 353 | | - char *name; |
|---|
| 354 | 355 | |
|---|
| 355 | 356 | if (!of_device_is_available(np)) |
|---|
| 356 | 357 | continue; |
|---|
| .. | .. |
|---|
| 359 | 360 | gpiobase = of_get_property(np, "ralink,gpio-base", NULL); |
|---|
| 360 | 361 | if (!ngpio || !gpiobase) { |
|---|
| 361 | 362 | dev_err(&pdev->dev, "failed to load chip info\n"); |
|---|
| 363 | + of_node_put(np); |
|---|
| 362 | 364 | return -EINVAL; |
|---|
| 363 | 365 | } |
|---|
| 364 | 366 | |
|---|
| 365 | | - range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL); |
|---|
| 366 | | - range->name = name = (char *) &range[1]; |
|---|
| 367 | | - sprintf(name, "pio"); |
|---|
| 367 | + range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL); |
|---|
| 368 | + if (!range) { |
|---|
| 369 | + of_node_put(np); |
|---|
| 370 | + return -ENOMEM; |
|---|
| 371 | + } |
|---|
| 372 | + range->name = "pio"; |
|---|
| 368 | 373 | range->npins = __be32_to_cpu(*ngpio); |
|---|
| 369 | 374 | range->base = __be32_to_cpu(*gpiobase); |
|---|
| 370 | 375 | range->pin_base = range->base; |
|---|