From owner-svn-src-all@freebsd.org Wed Sep 20 20:48:23 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A7F7E22B66; Wed, 20 Sep 2017 20:48:23 +0000 (UTC) (envelope-from jhb@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 mx1.freebsd.org (Postfix) with ESMTPS id ED2177EE74; Wed, 20 Sep 2017 20:48:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8KKmMTh041114; Wed, 20 Sep 2017 20:48:22 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8KKmMNG041113; Wed, 20 Sep 2017 20:48:22 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201709202048.v8KKmMNG041113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 20 Sep 2017 20:48:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r323826 - in stable: 10/sys/dev/mly 11/sys/dev/mly X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/dev/mly 11/sys/dev/mly X-SVN-Commit-Revision: 323826 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Wed, 20 Sep 2017 20:48:23 -0000 Author: jhb Date: Wed Sep 20 20:48:21 2017 New Revision: 323826 URL: https://svnweb.freebsd.org/changeset/base/323826 Log: MFC 322270: Fix a NULL pointer dereference in mly_user_command(). If mly_user_command fails to allocate a command slot it jumps to an 'out' label used for error handling. The error handling code checks for a data buffer in 'mc->mc_data' to free before checking if 'mc' is NULL. Fix by just returning directly if we fail to allocate a command and only using the 'out' label for subsequent errors when there is actual cleanup to perform. PR: 217747 Reported by: PVS-Studio Modified: stable/10/sys/dev/mly/mly.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/mly/mly.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/dev/mly/mly.c ============================================================================== --- stable/10/sys/dev/mly/mly.c Wed Sep 20 20:40:49 2017 (r323825) +++ stable/10/sys/dev/mly/mly.c Wed Sep 20 20:48:21 2017 (r323826) @@ -2861,8 +2861,7 @@ mly_user_command(struct mly_softc *sc, struct mly_user /* allocate a command */ if (mly_alloc_command(sc, &mc)) { - error = ENOMEM; - goto out; /* XXX Linux version will wait for a command */ + return (ENOMEM); /* XXX Linux version will wait for a command */ } /* handle data size/direction */ @@ -2918,8 +2917,7 @@ mly_user_command(struct mly_softc *sc, struct mly_user out: if (mc->mc_data != NULL) free(mc->mc_data, M_DEVBUF); - if (mc != NULL) - mly_release_command(mc); + mly_release_command(mc); return(error); }