Fixes for the Integrator: - Handle failed allocations in the IM/PC bus attachment. - Use struct_size() for allocation. * tag 'integrator-fixes-armsoc' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator: ARM: integrator: impd1: use struct_size() in devm_kzalloc() gpio: pl061: handle failed allocations
Unified · Split
| @@ -390,10 +390,14 @@ static int __ref impd1_probe(struct lm_device *dev) · 389 unmodified lines | ||
| 390 | 390 | char *mmciname; |
| 391 | 391 | |
| 392 | 392 | lookup = devm_kzalloc(&dev->dev, |
| 393 | − sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup), | |
| 393 | + struct_size(lookup, table, 3), | |
| 394 | 394 | GFP_KERNEL); |
| 395 | 395 | chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL); |
| 396 | − mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id); | |
| 396 | + mmciname = devm_kasprintf(&dev->dev, GFP_KERNEL, | |
| 397 | + "lm%x:00700", dev->id); | |
| 398 | + if (!lookup || !chipname || !mmciname) | |
| 399 | + return -ENOMEM; | |
| 400 | + | |
| 397 | 401 | lookup->dev_id = mmciname; |
| 398 | 402 | /* |
| 399 | 403 | * Offsets on GPIO block 1: |