From owner-svn-src-all@FreeBSD.ORG Tue Nov 25 20:28:33 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99D701065676; Tue, 25 Nov 2008 20:28:33 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 896808FC0A; Tue, 25 Nov 2008 20:28:33 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAPKSXdw034316; Tue, 25 Nov 2008 20:28:33 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAPKSXnZ034315; Tue, 25 Nov 2008 20:28:33 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200811252028.mAPKSXnZ034315@svn.freebsd.org> From: Ulf Lilleengen Date: Tue, 25 Nov 2008 20:28:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185318 - head/sys/geom X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2008 20:28:33 -0000 Author: lulf Date: Tue Nov 25 20:28:33 2008 New Revision: 185318 URL: http://svn.freebsd.org/changeset/base/185318 Log: - Fix a potential NULL pointer reference. Note that this should not happen in practice, but it is a good programming practice and allows the kernel to not depend on userland correctness. - While there, make sizeof usage match the rest of the code. Found with: Coverity Prevent(tm) CID: 660, 662 Modified: head/sys/geom/geom_ccd.c Modified: head/sys/geom/geom_ccd.c ============================================================================== --- head/sys/geom/geom_ccd.c Tue Nov 25 20:02:47 2008 (r185317) +++ head/sys/geom/geom_ccd.c Tue Nov 25 20:28:33 2008 (r185318) @@ -709,8 +709,20 @@ g_ccd_create(struct gctl_req *req, struc g_topology_assert(); unit = gctl_get_paraml(req, "unit", sizeof (*unit)); + if (unit == NULL) { + gctl_error(req, "unit parameter not given"); + return; + } ileave = gctl_get_paraml(req, "ileave", sizeof (*ileave)); + if (ileave == NULL) { + gctl_error(req, "ileave parameter not given"); + return; + } nprovider = gctl_get_paraml(req, "nprovider", sizeof (*nprovider)); + if (nprovider == NULL) { + gctl_error(req, "nprovider parameter not given"); + return; + } /* Check for duplicate unit */ LIST_FOREACH(gp, &mp->geom, geom) { @@ -838,7 +850,11 @@ g_ccd_list(struct gctl_req *req, struct struct g_geom *gp; int i, unit, *up; - up = gctl_get_paraml(req, "unit", sizeof (int)); + up = gctl_get_paraml(req, "unit", sizeof (*up)); + if (up == NULL) { + gctl_error(req, "unit parameter not given"); + return; + } unit = *up; sb = sbuf_new_auto(); LIST_FOREACH(gp, &mp->geom, geom) {