]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: avoid dev->req_seq overflow
authorRobert Baldyga <r.baldyga@samsung.com>
Thu, 18 Sep 2014 15:13:07 +0000 (17:13 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 23 Sep 2014 18:44:31 +0000 (12:44 -0600)
Since dev->req_seq value is initialized from "reg" property of fdt node,
there is posibility, that address value contained in fdt is greater than
INT_MAX, and then value in dev->req_seq is negative which led to probe()
fail.

This patch fix this problem by ensuring that req_seq is positive, unless
it's one of errno codes.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/core/device.c

index ef41a9be3edc3d9cb20247f5026bd720a265d5a7..32e80e82b59c99f9ac5734c8f3dadc7c3b0c5f28 100644 (file)
@@ -109,6 +109,8 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
        dev->seq = -1;
 #ifdef CONFIG_OF_CONTROL
        dev->req_seq = fdtdec_get_int(gd->fdt_blob, of_offset, "reg", -1);
        dev->seq = -1;
 #ifdef CONFIG_OF_CONTROL
        dev->req_seq = fdtdec_get_int(gd->fdt_blob, of_offset, "reg", -1);
+       if (!IS_ERR_VALUE(dev->req_seq))
+               dev->req_seq &= INT_MAX;
        if (uc->uc_drv->name && of_offset != -1) {
                fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name, of_offset,
                                     &dev->req_seq);
        if (uc->uc_drv->name && of_offset != -1) {
                fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name, of_offset,
                                     &dev->req_seq);