Free allocated sbufs before returning ENOMEM.

PR:		128335
Submitted by:	Mateusz Guzik <mjguzik@gmail.com>
MFC after:	2 week
This commit is contained in:
Christian Brueffer 2010-01-08 22:58:50 +00:00
parent 37dc3d28cb
commit 30215f483e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201848

View File

@ -935,8 +935,10 @@ cpufreq_levels_sysctl(SYSCTL_HANDLER_ARGS)
/* Get settings from the device and generate the output string. */
count = CF_MAX_LEVELS;
levels = malloc(count * sizeof(*levels), M_TEMP, M_NOWAIT);
if (levels == NULL)
if (levels == NULL) {
sbuf_delete(&sb);
return (ENOMEM);
}
error = CPUFREQ_LEVELS(sc->dev, levels, &count);
if (error) {
if (error == E2BIG)
@ -974,8 +976,10 @@ cpufreq_settings_sysctl(SYSCTL_HANDLER_ARGS)
/* Get settings from the device and generate the output string. */
set_count = MAX_SETTINGS;
sets = malloc(set_count * sizeof(*sets), M_TEMP, M_NOWAIT);
if (sets == NULL)
if (sets == NULL) {
sbuf_delete(&sb);
return (ENOMEM);
}
error = CPUFREQ_DRV_SETTINGS(dev, sets, &set_count);
if (error)
goto out;