From owner-svn-src-all@FreeBSD.ORG Wed Oct 10 18:34:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7CE3B2B6; Wed, 10 Oct 2012 18:34:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 66B2C8FC0A; Wed, 10 Oct 2012 18:34:16 +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 q9AIYGmM079117; Wed, 10 Oct 2012 18:34:16 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9AIYGsN079115; Wed, 10 Oct 2012 18:34:16 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201210101834.q9AIYGsN079115@svn.freebsd.org> From: Alexander Motin Date: Wed, 10 Oct 2012 18:34:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241405 - head/sys/cam X-SVN-Group: head 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.14 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, 10 Oct 2012 18:34:16 -0000 Author: mav Date: Wed Oct 10 18:34:15 2012 New Revision: 241405 URL: http://svn.freebsd.org/changeset/base/241405 Log: Really handle xpt_compile_path() error in xpt_bus_register() instead of print error message and probably crash just after it on NULL dereference. Found by: Clang Static Analyzer Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Wed Oct 10 18:10:11 2012 (r241404) +++ head/sys/cam/cam_xpt.c Wed Oct 10 18:34:15 2012 (r241405) @@ -3898,8 +3898,11 @@ xpt_bus_register(struct cam_sim *sim, de status = xpt_compile_path(path, /*periph*/NULL, sim->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); - if (status != CAM_REQ_CMP) - printf("xpt_compile_path returned %d\n", status); + if (status != CAM_REQ_CMP) { + xpt_release_bus(new_bus); + free(path, M_CAMXPT); + return (CAM_RESRC_UNAVAIL); + } xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); cpi.ccb_h.func_code = XPT_PATH_INQ;