lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 14 Feb 2014 11:54:28 +0000
From:	Ian Abbott <abbotti@....co.uk>
To:	Chase Southwood <chase.southwood@...oo.com>,
	gregkh@...uxfoundation.org
CC:	hsweeten@...ionengravers.com, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] Staging: comedi: clean up conditional statement in
 addi_apci_3xxx.c

On 2014-02-14 01:02, Chase Southwood wrote:
> In this conditional statement, if (chan < 16), but the instruction passed
> in data[0] is INSN_CONFIG_DIO_QUERY, the function does not return early,
> but the else-branch does not get executed either.  As a result, mask
> would be used uninitialized in the next line.  We want
> comedi_dio_insn_config() to use a chan_mask based on the chanspec for the
> INSN_CONFIG_DIO_QUERY instruction, so mask should be initialized to 0.
> Then, if instead the instruction is INSN_CONFIG_DIO_{INPUT,OUTPUT}, we
> return an error if (chan < 16) as these are invalid instructions for
> ports 0 and 1, or update the mask otherwise, so all the io_bits are
> modified for port 2.  This ensures that mask is always initialized by the
> time it is used.
>
> Signed-off-by: Chase Southwood <chase.southwood@...oo.com>
> ---
>
> 2: Addressed all of the comments provided by Hartley regarding correct
> structure of this patch.
>
> Hopefully everything looks better!
>
>   drivers/staging/comedi/drivers/addi_apci_3xxx.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> index ceadf8e..1f3b668 100644
> --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> @@ -680,7 +680,7 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev,
>   				    unsigned int *data)
>   {
>   	unsigned int chan = CR_CHAN(insn->chanspec);
> -	unsigned int mask;
> +	unsigned int mask = 0;
>   	int ret;
>
>   	/*
> @@ -688,12 +688,13 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev,
>   	 * Port 1 (channels 8-15) are always outputs
>   	 * Port 2 (channels 16-23) are programmable i/o
>   	 */
> -	if (chan < 16) {
> -		if (data[0] != INSN_CONFIG_DIO_QUERY)
> +	if (data[0] != INSN_CONFIG_DIO_QUERY) {
> +		/* ignore all other instructions for ports 0 and 1 */
> +		if (chan < 16)
>   			return -EINVAL;
> -	} else {
> -		/* changing any channel in port 2 changes the entire port */
> -		mask = 0xff0000;
> +		else
> +			/* changing any channel in port 2 changes the entire port */
> +			mask = 0xff0000;
>   	}
>
>   	ret = comedi_dio_insn_config(dev, s, insn, data, mask);
>

Looks okay this time. :)

Reviewed-by: Ian Abbott <abbotti@....co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@....co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists