Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Apr 2016 00:58:27 +0800
From:      Kevin Lo <kevlo@FreeBSD.org>
To:        "Pedro F. Giffuni" <pfg@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r297526 - head/sys/geom/sched
Message-ID:  <20160403165827.GA24850@ns.kevlo.org>
In-Reply-To: <201604031625.u33GPpnK088911@repo.freebsd.org>
References:  <201604031625.u33GPpnK088911@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 03, 2016 at 04:25:51PM +0000, Pedro F. Giffuni wrote:
> 
> Author: pfg
> Date: Sun Apr  3 16:25:51 2016
> New Revision: 297526
> URL: https://svnweb.freebsd.org/changeset/base/297526
> 
> Log:
>   g_sched_destroy(): prevent return of uninitialized scalar variable.
>   
>   For the !gsp case there some chance of returning an uninitialized
>   return value. Prevent that from happening by initializing the
>   error value.

Hmm, wouldn't it be better to initialize 'error' before use?

Index: sys/geom/sched/g_sched.c
===================================================================
--- sys/geom/sched/g_sched.c	(revision 297527)
+++ sys/geom/sched/g_sched.c	(working copy)
@@ -1236,7 +1236,7 @@ g_sched_destroy(struct g_geom *gp, boolean_t force
 	struct g_provider *pp, *oldpp = NULL;
 	struct g_sched_softc *sc;
 	struct g_gsched *gsp;
-	int error;
+	int error = 0;
 
 	g_topology_assert();
 	sc = gp->softc;
@@ -1316,8 +1316,7 @@ g_sched_destroy(struct g_geom *gp, boolean_t force
 		gsp->gs_fini(sc->sc_data);
 		g_gsched_unref(gsp);
 		sc->sc_gsched = NULL;
-	} else
-		error = 0;
+	}
 
 	if ((sc->sc_flags & G_SCHED_PROXYING) && oldpp) {
 		error = g_destroy_proxy(gp, oldpp);
>   
>   CID:	1006421
> 
> Modified:
>   head/sys/geom/sched/g_sched.c
> 
> Modified: head/sys/geom/sched/g_sched.c
> ==============================================================================
> --- head/sys/geom/sched/g_sched.c	Sun Apr  3 14:40:54 2016	(r297525)
> +++ head/sys/geom/sched/g_sched.c	Sun Apr  3 16:25:51 2016	(r297526)
> @@ -1316,7 +1316,8 @@ g_sched_destroy(struct g_geom *gp, boole
>  		gsp->gs_fini(sc->sc_data);
>  		g_gsched_unref(gsp);
>  		sc->sc_gsched = NULL;
> -	}
> +	} else
> +		error = 0;
>  
>  	if ((sc->sc_flags & G_SCHED_PROXYING) && oldpp) {
>  		error = g_destroy_proxy(gp, oldpp);
> 
> 



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