NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/39110: Suspect typecast in src/sys/dev/ld.c
>Number: 39110
>Category: kern
>Synopsis: Suspect typecast in src/sys/dev/ld.c
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 06 13:45:00 +0000 2008
>Originator: Paul Goyette
>Release: 4.99.67
>Organization:
>Environment:
quicky:dev {285} uname -a
NetBSD quicky.whooppee.com 4.99.66 NetBSD 4.99.66 (QUICKY (ASUS M2N32 WS)
2008-06-20 03:02:36) #1: Fri Jun 20 04:58:08 PDT 2008
paul%speedy.whooppee.com@localhost:/build/obj/amd64/sys/arch/amd64/compile/QUICKY
amd64
quicky:dev {286}
>Description:
In src/sys/dev/ld.c there is a typecast of a "struct device *" to a "struct
ld_softc *". While this may work today due to fortuitous alignment of the
structures, it is likely to cause problems in the future, especially if the
"separate softc from device_t" project reaches this driver.
>How-To-Repeat:
Inspect the code
>Fix:
The following patch replaces the typecast with use of device_private().
Although it adds a couple of instructions, it's not on a commonly-used code
path so will have negligible performance or memory-footprint impact.
Index: ld.c
===================================================================
RCS file: /build/cvsroot/src/sys/dev/ld.c,v
retrieving revision 1.59
diff -u -p -r1.59 ld.c
--- ld.c 11 Jun 2008 12:41:22 -0000 1.59
+++ ld.c 5 Jul 2008 15:28:47 -0000
@@ -915,6 +915,6 @@ ld_set_properties(struct ld_softc *ld)
static void
ld_config_interrupts (struct device *d)
{
- struct ld_softc *sc = (struct ld_softc *)d;
+ struct ld_softc *sc = (struct ld_softc *)device_private(d);
dkwedge_discover(&sc->sc_dk);
}
Home |
Main Index |
Thread Index |
Old Index