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

Commit daf65bd1 authored by Liam Mark's avatar Liam Mark Committed by Patrick Daly
Browse files

drivers: dma-removed: page align size on free



Fix removed ops memory leak which occurs when non-page
aligned memory is freed.

On free we need to page align the amount of memory being
freed otherwise we risk rounding down the size of the
allocation to the page boundary which would leak one page.

Change-Id: Idabce39cad526eeaf073748edb227b2edd76f40e
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent 57e6f446
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
/*
/*
 *
 *
 *  Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 *  Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 *  Copyright (C) 2000-2004 Russell King
 *  Copyright (C) 2000-2004 Russell King
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
@@ -294,6 +294,7 @@ void removed_free(struct device *dev, size_t size, void *cpu_addr,
	bool no_kernel_mapping = attrs & DMA_ATTR_NO_KERNEL_MAPPING;
	bool no_kernel_mapping = attrs & DMA_ATTR_NO_KERNEL_MAPPING;
	struct removed_region *dma_mem = dev->removed_mem;
	struct removed_region *dma_mem = dev->removed_mem;


	size = PAGE_ALIGN(size);
	if (!no_kernel_mapping)
	if (!no_kernel_mapping)
		iounmap(cpu_addr);
		iounmap(cpu_addr);
	mutex_lock(&dma_mem->lock);
	mutex_lock(&dma_mem->lock);