Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e81c022a authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Ulf Hansson
Browse files

mmc: wbsd: safer check if dma_addr is valid DMA address



host->dma_addr can store a value that is not returned by the DMA API,
so it is safer to check if is a valid DMA address indirectly.

Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent e28d6f04
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1437,11 +1437,14 @@ static void wbsd_request_dma(struct wbsd_host *host, int dma)

static void wbsd_release_dma(struct wbsd_host *host)
{
	if (!dma_mapping_error(mmc_dev(host->mmc), host->dma_addr)) {
	/*
	 * host->dma_addr is valid here iff host->dma_buffer is not NULL.
	 */
	if (host->dma_buffer) {
		dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
			WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
	}
		kfree(host->dma_buffer);
	}
	if (host->dma >= 0)
		free_dma(host->dma);