Skip to content

Commit 9d28cc8

Browse files
chleroyScott Wood
authored andcommitted
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>
1 parent 9100d20 commit 9d28cc8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎arch/powerpc/sysdev/cpm_common.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ unsigned long cpm_muram_alloc(unsigned long size, unsigned long align)
147147
spin_lock_irqsave(&cpm_muram_lock, flags);
148148
cpm_muram_info.alignment = align;
149149
start = rh_alloc(&cpm_muram_info, size, "commproc");
150-
memset_io(cpm_muram_addr(start), 0, size);
150+
if (!IS_ERR_VALUE(start))
151+
memset_io(cpm_muram_addr(start), 0, size);
151152
spin_unlock_irqrestore(&cpm_muram_lock, flags);
152153

153154
return start;

0 commit comments

Comments
 (0)