Date: Fri, 24 Jan 2014 00:42:18 +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: r261094 - head/sys/dev/fdt Message-ID: <201401240042.s0O0gIKR049235@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Fri Jan 24 00:42:18 2014 New Revision: 261094 URL: http://svnweb.freebsd.org/changeset/base/261094 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. Reviewed by: brooks, nwhitehorn Modified: head/sys/dev/fdt/fdt_common.c Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Fri Jan 24 00:41:02 2014 (r261093) +++ head/sys/dev/fdt/fdt_common.c Fri Jan 24 00:42:18 2014 (r261094) @@ -483,11 +483,23 @@ fdt_intr_to_rl(device_t dev, phandle_t n 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, intr[i]); resource_list_add(rl, SYS_RES_IRQ, k, intr[i], intr[i],
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401240042.s0O0gIKR049235>