From owner-svn-src-all@FreeBSD.ORG Mon Aug 20 20:40:15 2012 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 232AB1065676; Mon, 20 Aug 2012 20:40:15 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E3BE8FC18; Mon, 20 Aug 2012 20:40:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7KKeEaO089793; Mon, 20 Aug 2012 20:40:14 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7KKeEP0089791; Mon, 20 Aug 2012 20:40:14 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201208202040.q7KKeEP0089791@svn.freebsd.org> From: Sergey Kandaurov Date: Mon, 20 Aug 2012 20:40:14 +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: r239468 - head/sbin/camcontrol 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: Mon, 20 Aug 2012 20:40:15 -0000 Author: pluknet Date: Mon Aug 20 20:40:14 2012 New Revision: 239468 URL: http://svn.freebsd.org/changeset/base/239468 Log: Avoid segfault in the 'smpphylist' subcommand. Initialize devlist.dev_queue tail queue early enough before its any potential traversal in freebusdevlist() when in smpphylist error path. Reported by: Pavel Polyakov (on irc) Reviewed by: ken MFC after: 5 days Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Mon Aug 20 19:26:43 2012 (r239467) +++ head/sbin/camcontrol/camcontrol.c Mon Aug 20 20:40:14 2012 (r239468) @@ -5459,6 +5459,7 @@ smpphylist(struct cam_device *device, in bzero(&(&ccb->ccb_h)[1], sizeof(union ccb) - sizeof(struct ccb_hdr)); + STAILQ_INIT(&devlist.dev_queue); rgrequest = malloc(sizeof(*rgrequest)); if (rgrequest == NULL) { @@ -5527,7 +5528,6 @@ smpphylist(struct cam_device *device, in goto bailout; } - STAILQ_INIT(&devlist.dev_queue); devlist.path_id = device->path_id; retval = buildbusdevlist(&devlist);