diff options
author | zbb <zbb@FreeBSD.org> | 2016-02-18 11:53:57 +0000 |
---|---|---|
committer | zbb <zbb@FreeBSD.org> | 2016-02-18 11:53:57 +0000 |
commit | d520d79a17fed19e354e59fe3a6046fa89bcf8e3 (patch) | |
tree | 8e2cc87755ba43f94745987e741c0d763c930c38 /sys/dev | |
parent | 607785ea5a20b76ef6040a64af9b904fc9fa1a32 (diff) | |
download | FreeBSD-src-d520d79a17fed19e354e59fe3a6046fa89bcf8e3.zip FreeBSD-src-d520d79a17fed19e354e59fe3a6046fa89bcf8e3.tar.gz |
Fix bug in ofwbus_release_resource() for non-ofwbus descendants
Resource list for devices that are not ofwbus descendants, but
got to ofwbus method via bus_generic_release_resource() call chain,
cannot be found using BUS_GET_RESOURCE_LIST() used by ofwbus.
In that case, changing device's resource list should be avoided
(will not contain resource list prepared by ofw or simplebus).
Pointy-hat to: zbb
Reviewed by: wma
Obtained from: Semihalf
Sponsored by: Cavium
Differential Revision: https://reviews.freebsd.org/D5304
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ofw/ofwbus.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c index 142ee1a..23e604a 100644 --- a/sys/dev/ofw/ofwbus.c +++ b/sys/dev/ofw/ofwbus.c @@ -271,12 +271,17 @@ ofwbus_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { struct resource_list_entry *rle; + int passthrough; int error; - /* Clean resource list entry */ - rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), type, rid); - if (rle != NULL) - rle->res = NULL; + passthrough = (device_get_parent(child) != bus); + if (!passthrough) { + /* Clean resource list entry */ + rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), + type, rid); + if (rle != NULL) + rle->res = NULL; + } if ((rman_get_flags(r) & RF_ACTIVE) != 0) { error = bus_deactivate_resource(child, type, rid, r); |