Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/stand/boot Add bound check of a controller ...



details:   https://anonhg.NetBSD.org/src/rev/9e34e2666bb7
branches:  trunk
changeset: 325654:9e34e2666bb7
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Thu Jan 02 18:45:24 2014 +0000

description:
Add bound check of a controller number in scrun().

Noticed by miod@openbsd.

diffstat:

 sys/arch/luna68k/stand/boot/sc.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (26 lines):

diff -r c9b6c741c2df -r 9e34e2666bb7 sys/arch/luna68k/stand/boot/sc.c
--- a/sys/arch/luna68k/stand/boot/sc.c  Thu Jan 02 18:29:01 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/sc.c  Thu Jan 02 18:45:24 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sc.c,v 1.5 2014/01/02 17:47:23 tsutsui Exp $   */
+/*     $NetBSD: sc.c,v 1.6 2014/01/02 18:45:24 tsutsui Exp $   */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -254,8 +254,14 @@
 scrun(int ctlr, int slave, u_char *cdb, int cdblen, u_char *buf, int len,
     volatile int *lock)
 {
-       struct scsi_softc *hs = &scsi_softc[ctlr];
-       struct scsidevice *hd = (struct scsidevice *) hs->sc_hc->hp_addr;
+       struct scsi_softc *hs;
+       struct scsidevice *hd;
+
+       if (ctlr < 0 || ctlr >= NSC)
+               return 0;
+
+       hs = &scsi_softc[ctlr];
+       hd = (struct scsidevice *)hs->sc_hc->hp_addr;
 
        if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
                return(0);



Home | Main Index | Thread Index | Old Index