Date: Sun, 2 Feb 2014 16:56:41 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261405 - head/sys/dev/fdt Message-ID: <201402021656.s12GufkW037507@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Sun Feb 2 16:56:40 2014 New Revision: 261405 URL: http://svnweb.freebsd.org/changeset/base/261405 Log: Be more robust with malformed interrupt config data. Instead of crashing or going into a near-infinite loop, warn and make potentially-reasonable assumptions. Modified: head/sys/dev/fdt/simplebus.c Modified: head/sys/dev/fdt/simplebus.c ============================================================================== --- head/sys/dev/fdt/simplebus.c Sun Feb 2 16:42:26 2014 (r261404) +++ head/sys/dev/fdt/simplebus.c Sun Feb 2 16:56:40 2014 (r261405) @@ -287,11 +287,23 @@ simplebus_setup_dinfo(device_t dev, phan nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), (void **)&intr); if (nintr > 0) { - iparent = 0; - OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)); - OF_searchencprop(OF_xref_phandle(iparent), "#interrupt-cells", - &icells, sizeof(icells)); + if (OF_searchencprop(node, "interrupt-parent", &iparent, + sizeof(iparent)) == -1) { + device_printf(dev, "No interrupt-parent found, " + "assuming direct parent\n"); + iparent = OF_parent(node); + } + if (OF_searchencprop(OF_xref_phandle(iparent), + "#interrupt-cells", &icells, sizeof(icells)) == -1) { + device_printf(dev, "Missing #interrupt-cells property, " + "assuming <1>\n"); + icells = 1; + } + if (icells < 1 || icells > nintr) { + device_printf(dev, "Invalid #interrupt-cells property " + "value <%d>, assuming <1>\n", icells); + icells = 1; + } for (i = 0, k = 0; i < nintr; i += icells, k++) { intr[i] = ofw_bus_map_intr(dev, iparent, icells, &intr[i]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402021656.s12GufkW037507>