Re: [patch 2/2 v2] serial: jsm: some off by one bugs

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

 



On Tue, Mar 17, 2015 at 12:17:28PM +0300, Dan Carpenter wrote:
> "brd->nasync" amd "brd->maxports" are the same.  They hold the number of
> filled out channels in the brd->channels[] array.  These tests should
> be ">=" instead of ">" so that we don't read one element past the end.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> v2: Thadeu Cascardo noticed another off by one that I missed.
> 

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxxxxxxx>

> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
> index bfb0681..4eb12a9 100644
> --- a/drivers/tty/serial/jsm/jsm_cls.c
> +++ b/drivers/tty/serial/jsm/jsm_cls.c
> @@ -570,7 +570,7 @@ static inline void cls_parse_isr(struct jsm_board *brd, uint port)
>  	 * verified in the interrupt routine.
>  	 */
> 
> -	if (port > brd->nasync)
> +	if (port >= brd->nasync)
>  		return;
> 
>  	ch = brd->channels[port];
> diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
> index 7291c21..932b2ac 100644
> --- a/drivers/tty/serial/jsm/jsm_neo.c
> +++ b/drivers/tty/serial/jsm/jsm_neo.c
> @@ -724,7 +724,7 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
>  	if (!brd)
>  		return;
> 
> -	if (port > brd->maxports)
> +	if (port >= brd->maxports)
>  		return;
> 
>  	ch = brd->channels[port];
> @@ -840,7 +840,7 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
>  	if (!brd)
>  		return;
> 
> -	if (port > brd->maxports)
> +	if (port >= brd->maxports)
>  		return;
> 
>  	ch = brd->channels[port];
> @@ -1180,7 +1180,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
>  			 */
> 
>  			/* Verify the port is in range. */
> -			if (port > brd->nasync)
> +			if (port >= brd->nasync)
>  				continue;
> 
>  			ch = brd->channels[port];
> 

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux