From owner-svn-src-head@freebsd.org Mon Feb 19 19:08:26 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5EEA8F1B4F8; Mon, 19 Feb 2018 19:08:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 12FD186122; Mon, 19 Feb 2018 19:08:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 093DE1E8B2; Mon, 19 Feb 2018 19:08:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1JJ8P3P081955; Mon, 19 Feb 2018 19:08:25 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1JJ8PZ2081954; Mon, 19 Feb 2018 19:08:25 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201802191908.w1JJ8PZ2081954@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 19 Feb 2018 19:08:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329600 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 329600 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2018 19:08:26 -0000 Author: kib Date: Mon Feb 19 19:08:25 2018 New Revision: 329600 URL: https://svnweb.freebsd.org/changeset/base/329600 Log: Do not free(9) uninitialized pointer. Reported and tested by: allanjude Reviewed by: markj Sponsored by: The FreeBSD Foundation Modified: head/sys/ufs/ffs/ffs_subr.c Modified: head/sys/ufs/ffs/ffs_subr.c ============================================================================== --- head/sys/ufs/ffs/ffs_subr.c Mon Feb 19 19:01:46 2018 (r329599) +++ head/sys/ufs/ffs/ffs_subr.c Mon Feb 19 19:08:25 2018 (r329600) @@ -174,12 +174,17 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsuper *fsp = NULL; if (altsuperblock != -1) { - if ((ret = readsuper(devfd, fsp, altsuperblock, readfunc)) != 0) + ret = readsuper(devfd, fsp, altsuperblock, readfunc); + if (*fsp != NULL) + (*fsp)->fs_csp = NULL; + if (ret != 0) return (ret); } else { for (i = 0; sblock_try[i] != -1; i++) { - if ((ret = readsuper(devfd, fsp, sblock_try[i], - readfunc)) == 0) + ret = readsuper(devfd, fsp, sblock_try[i], readfunc); + if (*fsp != NULL) + (*fsp)->fs_csp = NULL; + if (ret == 0) break; if (ret == ENOENT) continue; @@ -188,17 +193,17 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsuper if (sblock_try[i] == -1) return (ENOENT); } + /* - * If not filling in summary information, NULL out fs_csp and return. + * Not filling in summary information, return. */ - fs = *fsp; - if (filltype == NULL) { - fs->fs_csp = NULL; + if (filltype == NULL) return (0); - } + /* * Read in the superblock summary information. */ + fs = *fsp; size = fs->fs_cssize; blks = howmany(size, fs->fs_fsize); if (fs->fs_contigsumsize > 0)