Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2010 22:58:50 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r201848 - head/sys/kern
Message-ID:  <201001082258.o08MworN017690@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Fri Jan  8 22:58:50 2010
New Revision: 201848
URL: http://svn.freebsd.org/changeset/base/201848

Log:
  Free allocated sbufs before returning ENOMEM.
  
  PR:		128335
  Submitted by:	Mateusz Guzik <mjguzik@gmail.com>
  MFC after:	2 week

Modified:
  head/sys/kern/kern_cpu.c

Modified: head/sys/kern/kern_cpu.c
==============================================================================
--- head/sys/kern/kern_cpu.c	Fri Jan  8 22:56:46 2010	(r201847)
+++ head/sys/kern/kern_cpu.c	Fri Jan  8 22:58:50 2010	(r201848)
@@ -935,8 +935,10 @@ cpufreq_levels_sysctl(SYSCTL_HANDLER_ARG
 	/* 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_A
 	/* 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001082258.o08MworN017690>