Module Name:    src
Committed By:   bouyer
Date:           Fri May 22 10:34:13 UTC 2015

Modified Files:
        src/sys/arch/xen/xen: xenevt.c

Log Message:
Fix off by one error, pointed out by Wei Liu in port-xen/49919


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/xen/xenevt.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/arch/xen/xen/xenevt.c
diff -u src/sys/arch/xen/xen/xenevt.c:1.41 src/sys/arch/xen/xen/xenevt.c:1.42
--- src/sys/arch/xen/xen/xenevt.c:1.41	Fri Jul 25 08:10:35 2014
+++ src/sys/arch/xen/xen/xenevt.c	Fri May 22 10:34:13 2015
@@ -1,4 +1,4 @@
-/*      $NetBSD: xenevt.c,v 1.41 2014/07/25 08:10:35 dholland Exp $      */
+/*      $NetBSD: xenevt.c,v 1.42 2015/05/22 10:34:13 bouyer Exp $      */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.41 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.42 2015/05/22 10:34:13 bouyer Exp $");
 
 #include "opt_xen.h"
 #include <sys/param.h>
@@ -489,7 +489,7 @@ xenevt_fwrite(struct file *fp, off_t *of
 	if (uio->uio_resid == 0)
 		return (0);
 	nentries = uio->uio_resid / sizeof(uint16_t);
-	if (nentries > NR_EVENT_CHANNELS)
+	if (nentries >= NR_EVENT_CHANNELS)
 		return EMSGSIZE;
 	chans = kmem_alloc(nentries * sizeof(uint16_t), KM_SLEEP);
 	if (chans == NULL)
@@ -582,7 +582,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_unbind *unbind = addr;
 		
-		if (unbind->port > NR_EVENT_CHANNELS)
+		if (unbind->port >= NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(&devevent_lock);
 		if (devevent[unbind->port] != d) {
@@ -603,7 +603,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_notify *notify = addr;
 		
-		if (notify->port > NR_EVENT_CHANNELS)
+		if (notify->port >= NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(&devevent_lock);
 		if (devevent[notify->port] != d) {

Reply via email to