diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-04-06 12:10:05 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-04-06 12:10:05 +0000 |
commit | 5e6f35da11934357be45cdf737763250b580b738 (patch) | |
tree | 49213255fd6c69eff1deeb04e25d2441c83c6ae4 /sys/dev | |
parent | 2f84474d62456edce633a813fbae14639158df98 (diff) |
Convert memory extract routine to return errno-based errors.
Also check that mem is not NULL, as its part of the FDT API
and should make sure it's not accessing a null pointer.
ok bmercer@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ofw/fdt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index 1ad9611f670..cdb588b3f5c 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.7 2016/04/06 11:42:50 patrick Exp $ */ +/* $OpenBSD: fdt.c,v 1.8 2016/04/06 12:10:04 patrick Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net> @@ -498,26 +498,26 @@ fdt_get_memory_address(void *node, int idx, struct fdt_memory *mem) void *parent; int ac, sc, off, ret, *in, inlen; - if (node == NULL) - return 1; + if (node == NULL || mem == NULL) + return EINVAL; parent = fdt_parent_node(node); if (parent == NULL) - return 1; + return EINVAL; /* We only support 32-bit (1), and 64-bit (2) wide addresses here. */ ret = fdt_node_property_int(parent, "#address-cells", &ac); if (ret != 1 || ac <= 0 || ac > 2) - return 1; + return EINVAL; /* We only support 32-bit (1), and 64-bit (2) wide sizes here. */ ret = fdt_node_property_int(parent, "#size-cells", &sc); if (ret != 1 || sc <= 0 || sc > 2) - return 1; + return EINVAL; inlen = fdt_node_property(node, "reg", (char **)&in) / sizeof(int); if (inlen < ((idx + 1) * (ac + sc))) - return 1; + return EINVAL; off = idx * (ac + sc); |