# \[PATCH\] rheap.c rh\_alloc\_fixed

- From: Rune Torgersen \<hidden\>
- Date: 2005-08-29 22:43:37 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2005/08/9400731
- Thread: https://ratatoskr.run/linuxppc-dev/2005/08/9400731/t.md

```text
rh_alloc_fixed() used by cpm_dpalloc_fixed incorrectly returned next
free area=20
if the requested fixed area is not available.
This fixes it to return an error if requested area is not available.

Signed-off-by Rune Torgersen [ref]

Index: linux-innsys/arch/ppc/lib/rheap.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- linux-innsys/arch/ppc/lib/rheap.c	(revision 29)
+++ linux-innsys/arch/ppc/lib/rheap.c	(working copy)
@@ -522,6 +522,10 @@
 	if (blk =3D=3D NULL)
 		return ERR_PTR(-ENOMEM);
=20
+	/* make sure block actually fits */
+	if (bs > s )=20
+		return ERR_PTR(-ENOMEM);
+
 	/* Perfect fit */
 	if (bs =3D=3D s && be =3D=3D e) {
 		/* Move from free list to taken list */
```
