Module Name: src Committed By: msaitoh Date: Thu Sep 19 03:37:31 UTC 2019
Modified Files: src/sys/dev/scsipi: scsipi_base.c Log Message: Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag(). Found by kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/dev/scsipi/scsipi_base.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/scsipi/scsipi_base.c diff -u src/sys/dev/scsipi/scsipi_base.c:1.182 src/sys/dev/scsipi/scsipi_base.c:1.183 --- src/sys/dev/scsipi/scsipi_base.c:1.182 Thu Mar 28 10:44:29 2019 +++ src/sys/dev/scsipi/scsipi_base.c Thu Sep 19 03:37:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_base.c,v 1.182 2019/03/28 10:44:29 kardel Exp $ */ +/* $NetBSD: scsipi_base.c,v 1.183 2019/09/19 03:37:31 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.182 2019/03/28 10:44:29 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.183 2019/09/19 03:37:31 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -367,7 +367,7 @@ scsipi_get_tag(struct scsipi_xfer *xs) #endif bit -= 1; - periph->periph_freetags[word] &= ~(1 << bit); + periph->periph_freetags[word] &= ~(1U << bit); tag = (word << 5) | bit; /* XXX Should eventually disallow this completely. */ @@ -398,7 +398,7 @@ scsipi_put_tag(struct scsipi_xfer *xs) word = xs->xs_tag_id >> 5; bit = xs->xs_tag_id & 0x1f; - periph->periph_freetags[word] |= (1 << bit); + periph->periph_freetags[word] |= (1U << bit); } /*