Do not leak the OFW memory when the result does not satisfy our alignment

requirement.

While here, fix style(9) issues.
This commit is contained in:
Luiz Otavio O Souza 2015-01-30 14:09:07 +00:00
parent 33c380b096
commit 9855acef2a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277928

View File

@ -459,11 +459,16 @@ OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf)
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);