From 69131979da764dc40c72b67d2266ef970b612c83 Mon Sep 17 00:00:00 2001 From: brueffer Date: Fri, 8 Jan 2010 22:58:50 +0000 Subject: [PATCH] Free allocated sbufs before returning ENOMEM. PR: 128335 Submitted by: Mateusz Guzik MFC after: 2 week --- sys/kern/kern_cpu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 9f7f6156704d..4c4f961931fc 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -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;