Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ieee1394 Fix illegal pointer manipulations that caus...



details:   https://anonhg.NetBSD.org/src/rev/8f0262757c0f
branches:  trunk
changeset: 520777:8f0262757c0f
user:      eeh <eeh%NetBSD.org@localhost>
date:      Wed Jan 16 01:47:36 2002 +0000

description:
Fix illegal pointer manipulations that cause alignment problems.

diffstat:

 sys/dev/ieee1394/fwohci.c    |  12 ++++++------
 sys/dev/ieee1394/fwohcivar.h |   3 ++-
 2 files changed, 8 insertions(+), 7 deletions(-)

diffs (68 lines):

diff -r dafaeff62469 -r 8f0262757c0f sys/dev/ieee1394/fwohci.c
--- a/sys/dev/ieee1394/fwohci.c Wed Jan 16 01:19:22 2002 +0000
+++ b/sys/dev/ieee1394/fwohci.c Wed Jan 16 01:47:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohci.c,v 1.49 2002/01/12 16:58:16 tsutsui Exp $      */
+/*     $NetBSD: fwohci.c,v 1.50 2002/01/16 01:47:36 eeh Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.49 2002/01/12 16:58:16 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.50 2002/01/16 01:47:36 eeh Exp $");
 
 #define DOUBLEBUF 1
 #define NO_THREAD 1
@@ -944,13 +944,12 @@
        int buf2cnt;
 #endif
 
-       fc = malloc(sizeof(*fc) + sizeof(*fb) * bufcnt, M_DEVBUF,
-           M_WAITOK|M_ZERO);
+       fc = malloc(sizeof(*fc), M_DEVBUF, M_WAITOK|M_ZERO);
        LIST_INIT(&fc->fc_handler);
        TAILQ_INIT(&fc->fc_buf);
        fc->fc_ctx = ctx;
+       fc->fc_buffers = fb = malloc(sizeof(*fb) * bufcnt, M_DEVBUF, M_WAITOK|M_ZERO);
        fc->fc_bufcnt = bufcnt;
-       fb = (struct fwohci_buf *)&fc[1];
 #if DOUBLEBUF
        TAILQ_INIT(&fc->fc_buf2); /* for isochronous */
        if (ctxtype == FWOHCI_CTX_ISO_MULTI) {
@@ -1051,6 +1050,7 @@
                fwohci_buf_free(sc, fb);
        }
 #endif /* DOUBLEBUF */
+       free(fc->fc_buffers, M_DEVBUF);
        free(fc, M_DEVBUF);
 }
 
@@ -2379,7 +2379,7 @@
 #ifdef DIAGNOSTIC
        if ((fb->fb_dmamap->dm_segs[0].ds_addr & 0x7ff) != 0)
                panic("fwohci_selfid_init: not aligned: %p (%ld) %p",
-                   (caddr_t)fb->fb_dmamap->dm_segs[0].ds_addr,
+                   (caddr_t)(unsigned long)fb->fb_dmamap->dm_segs[0].ds_addr,
                    (unsigned long)fb->fb_dmamap->dm_segs[0].ds_len, fb->fb_buf);
 #endif
        memset(fb->fb_buf, 0, fb->fb_dmamap->dm_segs[0].ds_len);
diff -r dafaeff62469 -r 8f0262757c0f sys/dev/ieee1394/fwohcivar.h
--- a/sys/dev/ieee1394/fwohcivar.h      Wed Jan 16 01:19:22 2002 +0000
+++ b/sys/dev/ieee1394/fwohcivar.h      Wed Jan 16 01:47:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohcivar.h,v 1.16 2001/12/29 12:26:32 ichiro Exp $    */
+/*     $NetBSD: fwohcivar.h,v 1.17 2002/01/16 01:47:37 eeh Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -110,6 +110,7 @@
        TAILQ_HEAD(fwohci_buf_s, fwohci_buf) fc_buf;
        struct fwohci_buf_s fc_buf2; /* for iso */
        LIST_HEAD(, fwohci_handler) fc_handler;
+       struct fwohci_buf *fc_buffers;
 };
 
 struct fwohci_uidtbl {



Home | Main Index | Thread Index | Old Index