powerpc: handle error case in cpm_muram_alloc()
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 21 Aug 2015 16:48:31 +0000 (18:48 +0200)
committerScott Wood <scottwood@freescale.com>
Tue, 27 Oct 2015 23:13:31 +0000 (18:13 -0500)
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>
arch/powerpc/sysdev/cpm_common.c

index e2ea51961979c0b766607d0b5d48e4152768a010..e00a5ee58fd71f5af33d105b41bb2f2897b2b098 100644 (file)
@@ -147,7 +147,8 @@ 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");
-       memset_io(cpm_muram_addr(start), 0, size);
+       if (!IS_ERR_VALUE(start))
+               memset_io(cpm_muram_addr(start), 0, size);
        spin_unlock_irqrestore(&cpm_muram_lock, flags);
 
        return start;