svn commit: r277928 - head/sys/dev/ofw
Luiz Otavio O Souza
loos at FreeBSD.org
Fri Jan 30 14:09:08 UTC 2015
Author: loos
Date: Fri Jan 30 14:09:07 2015
New Revision: 277928
URL: https://svnweb.freebsd.org/changeset/base/277928
Log:
Do not leak the OFW memory when the result does not satisfy our alignment
requirement.
While here, fix style(9) issues.
Modified:
head/sys/dev/ofw/openfirm.c
Modified: head/sys/dev/ofw/openfirm.c
==============================================================================
--- head/sys/dev/ofw/openfirm.c Fri Jan 30 13:03:36 2015 (r277927)
+++ head/sys/dev/ofw/openfirm.c Fri Jan 30 14:09:07 2015 (r277928)
@@ -459,11 +459,16 @@ OF_getencprop_alloc(phandle_t package, c
int i;
retval = OF_getprop_alloc(package, name, elsz, buf);
- if (retval == -1 || retval*elsz % 4 != 0)
+ if (retval == -1)
return (-1);
+ if (retval * elsz % 4 != 0) {
+ free(*buf, M_OFWPROP);
+ *buf = NULL;
+ return (-1);
+ }
cell = *buf;
- for (i = 0; i < retval*elsz/4; i++)
+ for (i = 0; i < retval * elsz / 4; i++)
cell[i] = be32toh(cell[i]);
return (retval);
More information about the svn-src-all
mailing list