Skip to contentSkip to conversation

mmc: dw_mmc: Handle return value from bounce_buffer_start()

PATCH New Marek Vasut 2 participants 2 messages Mar 23, 2019 – Mar 30, 2019 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: dw_mmc: Handle return value from bounce_buffer_start()

The bounce_buffer_start() can return -ENOMEM in case memory allocation failed. However, in that case, the bounce buffer address is the same as the possibly unaligned input address, and the cache maintenance operations were not applied to this address. This could cause subtle problems. Add handling for the bounce_buffer_start() return value to prevent such a problem from happening.

Cc Jaehoon Chung <[email protected]>
Cc Simon Glass <[email protected]>
---
 drivers/mmc/dw_mmc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/dw_mmc.c +8 -2
index 8278f1dacb..72570235cb 100644
@@ -261,14 +261,20 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 			dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET);
 		} else {
 			if (data->flags == MMC_DATA_READ) {
-				bounce_buffer_start(&bbstate, (void*)data->dest,
+				ret = bounce_buffer_start(&bbstate,
+						(void*)data->dest,
 						data->blocksize *
 						data->blocks, GEN_BB_WRITE);
 			} else {
-				bounce_buffer_start(&bbstate, (void*)data->src,
+				ret = bounce_buffer_start(&bbstate,
+						(void*)data->src,
 						data->blocksize *
 						data->blocks, GEN_BB_READ);
 			}
+
+			if (ret)
+				return ret;
+
 			dwmci_prepare_data(host, data, cur_idmac,
 					   bbstate.bounce_buffer);
 		}
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 mmc: dw_mmc: Handle return value from bounce_buffer_start()

Quoted 8 lines · Marek Vasut

The bounce_buffer_start() can return -ENOMEM in case memory allocation failed. However, in that case, the bounce buffer address is the same as the possibly unaligned input address, and the cache maintenance operations were not applied to this address. This could cause subtle problems. Add handling for the bounce_buffer_start() return value to prevent such a problem from happening.

Quoted 7 lines
Cc Jaehoon Chung <[email protected]>
Cc Simon Glass <[email protected]>
---
 drivers/mmc/dw_mmc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)