Re: [PATCH v4] bitops: Fix shift overflow in GENMASK macros

From: Max Filippov
Date: Fri Nov 14 2014 - 15:03:45 EST


Hi Maxime,

On Fri, Nov 14, 2014 at 5:07 PM, Maxime Coquelin <maxime.coquelin@xxxxxx> wrote:
> Looking at all GENMASK and GENMASK_ULL occurences in v3.18-rc4,
> I (only) found one possible candidate in drivers/spi/spi_xtensa-xtfpga.c:
>
> static u32 xtfpga_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
> u32 v, u8 bits)
> {
> struct xtfpga_spi *xspi = spi_master_get_devdata(spi->master);
>
> xspi->data = (xspi->data << bits) | (v & GENMASK(bits - 1, 0));
> ...
> }
>
> Max F., can xtfpga_spi_txrx_word() be called with "bits" = 32?

No, bits should never be greater than 16, because spi_master sets its
bits_per_word_mask to SPI_BPW_RANGE_MASK(1, 16).

--
Thanks.
-- Max
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/