]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.51/mmc-sunxi-avoid-invalid-pointer-calculation.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.51 / mmc-sunxi-avoid-invalid-pointer-calculation.patch
1 From d34712d2e3db9b241d0484a6e3839c6b7ef9df78 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Tue, 24 Feb 2015 10:47:27 +0100
4 Subject: mmc: sunxi: avoid invalid pointer calculation
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Arnd Bergmann <arnd@arndb.de>
10
11 commit d34712d2e3db9b241d0484a6e3839c6b7ef9df78 upstream.
12
13 The sunxi mmc driver tries to calculate a dma address by using pointer
14 arithmetic, which causes a warning when dma_addr_t is wider than a pointer:
15
16 drivers/mmc/host/sunxi-mmc.c: In function 'sunxi_mmc_init_idma_des':
17 drivers/mmc/host/sunxi-mmc.c:296:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
18 struct sunxi_idma_des *pdes_pa = (struct sunxi_idma_des *)host->sg_dma;
19 ^
20
21 To avoid this warning and to simplify the logic, this changes
22 the code to avoid the cast and calculate the correct address
23 manually. The behavior should be unchanged.
24
25 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
26 Acked-by: David Lanzendörfer <david.lanzendoerfer@o2s.ch>
27 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 drivers/mmc/host/sunxi-mmc.c | 5 +++--
32 1 file changed, 3 insertions(+), 2 deletions(-)
33
34 --- a/drivers/mmc/host/sunxi-mmc.c
35 +++ b/drivers/mmc/host/sunxi-mmc.c
36 @@ -294,7 +294,7 @@ static void sunxi_mmc_init_idma_des(stru
37 struct mmc_data *data)
38 {
39 struct sunxi_idma_des *pdes = (struct sunxi_idma_des *)host->sg_cpu;
40 - struct sunxi_idma_des *pdes_pa = (struct sunxi_idma_des *)host->sg_dma;
41 + dma_addr_t next_desc = host->sg_dma;
42 int i, max_len = (1 << host->idma_des_size_bits);
43
44 for (i = 0; i < data->sg_len; i++) {
45 @@ -306,8 +306,9 @@ static void sunxi_mmc_init_idma_des(stru
46 else
47 pdes[i].buf_size = data->sg[i].length;
48
49 + next_desc += sizeof(struct sunxi_idma_des);
50 pdes[i].buf_addr_ptr1 = sg_dma_address(&data->sg[i]);
51 - pdes[i].buf_addr_ptr2 = (u32)&pdes_pa[i + 1];
52 + pdes[i].buf_addr_ptr2 = (u32)next_desc;
53 }
54
55 pdes[0].config |= SDXC_IDMAC_DES0_FD;