Author: zbb
Date: Fri Nov  7 19:34:10 2014
New Revision: 274249
URL: https://svnweb.freebsd.org/changeset/base/274249

Log:
  Avoid panic in ofwbus caused by not released resource list entry
  
  After resource allocation and release, resource list entry
  stays non-NULL. This causes panic in ofwbus_alloc_resource()
  on subsequent resource allocation.
  Clean appropriate list entry on release to avoid this.
  
  Obtained from:        Semihalf
  Reviewed by:  ian
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/ofw/ofwbus.c

Modified: head/sys/dev/ofw/ofwbus.c
==============================================================================
--- head/sys/dev/ofw/ofwbus.c   Fri Nov  7 19:32:10 2014        (r274248)
+++ head/sys/dev/ofw/ofwbus.c   Fri Nov  7 19:34:10 2014        (r274249)
@@ -399,11 +399,17 @@ ofwbus_adjust_resource(device_t bus, dev
 }
 
 static int
-ofwbus_release_resource(device_t bus __unused, device_t child, int type,
+ofwbus_release_resource(device_t bus, device_t child, int type,
     int rid, struct resource *r)
 {
+       struct resource_list_entry *rle;
        int error;
 
+       /* 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);
                if (error)
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to