powerpc: handle error case in cpm_muram_alloc()

rh_alloc() returns (unsigned long)-ERRxx on error, which may
result in overwriting memory outside the MURAM AREA.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
Christophe Leroy 2015-08-21 18:48:31 +02:00 committed by Scott Wood
parent 9100d20c5b
commit 9d28cc811b
1 changed files with 2 additions and 1 deletions

View File

@ -147,6 +147,7 @@ unsigned long cpm_muram_alloc(unsigned long size, unsigned long align)
spin_lock_irqsave(&cpm_muram_lock, flags);
cpm_muram_info.alignment = align;
start = rh_alloc(&cpm_muram_info, size, "commproc");
if (!IS_ERR_VALUE(start))
memset_io(cpm_muram_addr(start), 0, size);
spin_unlock_irqrestore(&cpm_muram_lock, flags);