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  linux-hardening  linux-cve-announce  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:   Tue, 21 Nov 2023 06:57:56 +0100
From:   Jiri Slaby <jirislaby@...nel.org>
To:     Hugo Villeneuve <hugo@...ovil.com>, gregkh@...uxfoundation.org
Cc:     linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
        lech.perczak@...lingroup.com,
        Hugo Villeneuve <hvilleneuve@...onoff.com>
Subject: Re: [PATCH v2 1/1] serial: sc16is7xx: improve regmap debugfs by using
 one regmap per port

On 20. 11. 23, 17:39, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@...onoff.com>
> 
> With this current driver regmap implementation, it is hard to make sense
> of the register addresses displayed using the regmap debugfs interface,
> because they do not correspond to the actual register addresses documented
> in the datasheet. For example, register 1 is displayed as registers 04 thru
> 07:
...
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
...
>   #ifdef CONFIG_SERIAL_SC16IS7XX_SPI
>   static int sc16is7xx_spi_probe(struct spi_device *spi)
>   {
>   	const struct sc16is7xx_devtype *devtype;
> -	struct regmap *regmap;
> +	struct regmap *regmaps[2];

IMO, in all places, it would make sense to declare a VLA with 
devtype->nr_uart.

> +	unsigned int i;
>   	int ret;
>   
>   	/* Setup SPI bus */
> @@ -1732,11 +1736,20 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
>   		devtype = (struct sc16is7xx_devtype *)id_entry->driver_data;
>   	}
>   
> -	regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) |
> -			      (devtype->nr_uart - 1);
> -	regmap = devm_regmap_init_spi(spi, &regcfg);
> +	for (i = 0; i < devtype->nr_uart; i++) {
> +		regcfg.name = sc16is7xx_regmap_name(i);
> +		/*
> +		 * If read_flag_mask is 0, the regmap code sets it to a default
> +		 * of 0x80. Since we specify our own mask, we must add the READ
> +		 * bit ourselves:
> +		 */
> +		regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) |
> +			SC16IS7XX_SPI_READ_BIT;
> +		regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i);
> +		regmaps[i] = devm_regmap_init_spi(spi, &regcfg);

As you trip over the array until devtype->nr_uart which is of course up 
to 2. For now.

Or at least add an asserion: devtype->nr_uart <= 2 somewhere.

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ