svn commit: r241405 - head/sys/cam

Alexander Motin mav at FreeBSD.org
Wed Oct 10 18:34:16 UTC 2012


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;


More information about the svn-src-all mailing list