From owner-freebsd-hackers Sat Jan 15 19:32:50 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from laurasia.com.au (lauras.lnk.telstra.net [139.130.93.142]) by hub.freebsd.org (Postfix) with ESMTP id A83A41518B for ; Sat, 15 Jan 2000 19:32:45 -0800 (PST) (envelope-from mike@laurasia.com.au) Received: (from mike@localhost) by laurasia.com.au (8.9.1a/8.9.1) id LAA24167 for hackers@freebsd.org; Sat, 15 Jan 2000 11:32:37 +0800 (WST) Date: Sat, 15 Jan 2000 11:32:37 +0800 (WST) From: Michael Kennett Message-Id: <200001150332.LAA24167@laurasia.com.au> To: hackers@freebsd.org Subject: Use of newbus in sys/pci/pci.c Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello All, I have a question on the sys/pci/pci.c code, and its use of the newbus architecture. An example of the code in question is: static struct resource * pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { struct pci_devinfo *dinfo = device_get_ivars(child); ^^^^^ Looks wrong struct resource_list *rl = &dinfo->resources; return resource_list_alloc(rl, dev, child, type, rid, start, end, count, flags); } I don't understand the line that extracts the ivars from the child device. Isn't it the case that the ivars are a property of the bus device (dev)? In any case, the child device might not be directly descended from the pci bus (e.g. it could be attached thru' the bridge isab0: ). It strikes me that the assignment is unsafe. I would have thought that the code should be: static struct resource * pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { struct pci_devinfo *dinfo = device_get_ivars(dev); ^^^ CHANGED struct resource_list *rl = &dinfo->resources; return resource_list_alloc(rl, dev, child, type, rid, start, end, count, flags); } Why are the ivars extracted from the child, and not the bus device? Kind Regards, Mike Kennett (mike@laurasia.com.au) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message