9d41b3cce4ba88164bd1cb70c265ae98d3a09883
[openwrt/staging/aparcar.git] /
1 From 80a79a889ce5df16c5261ab2f1e8e63b94b78102 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Fri, 28 Oct 2016 07:58:46 +0200
4 Subject: [PATCH 1/8] mtd: m25p80: consider max message size in m25p80_read
5
6 Consider a message size limit when calculating the maximum amount
7 of data that can be read.
8
9 The message size limit has been introduced with 4.9, so cc it
10 to stable.
11
12 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
13 Cc: <stable@vger.kernel.org> # 4.9.x
14 Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
15 ---
16 drivers/mtd/devices/m25p80.c | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19 --- a/drivers/mtd/devices/m25p80.c
20 +++ b/drivers/mtd/devices/m25p80.c
21 @@ -174,7 +174,8 @@ static ssize_t m25p80_read(struct spi_no
22
23 t[1].rx_buf = buf;
24 t[1].rx_nbits = m25p80_rx_nbits(nor);
25 - t[1].len = min(len, spi_max_transfer_size(spi));
26 + t[1].len = min3(len, spi_max_transfer_size(spi),
27 + spi_max_message_size(spi) - t[0].len);
28 spi_message_add_tail(&t[1], &m);
29
30 ret = spi_sync(spi, &m);