svn commit: r208823 - head/sys/cam/ata

Alexander Motin mav at FreeBSD.org
Sat Jun 5 09:31:14 UTC 2010


Author: mav
Date: Sat Jun  5 09:31:13 2010
New Revision: 208823
URL: http://svn.freebsd.org/changeset/base/208823

Log:
  Add allocation error hadling.
  
  Found with:   Coverity Prevent(tm)
  CID:          3897

Modified:
  head/sys/cam/ata/ata_xpt.c

Modified: head/sys/cam/ata/ata_xpt.c
==============================================================================
--- head/sys/cam/ata/ata_xpt.c	Sat Jun  5 08:58:03 2010	(r208822)
+++ head/sys/cam/ata/ata_xpt.c	Sat Jun  5 09:31:13 2010	(r208823)
@@ -1210,6 +1210,12 @@ ata_scan_bus(struct cam_periph *periph, 
 		    !(work_ccb->cpi.hba_misc & PIM_NOBUSRESET) &&
 		    !timevalisset(&request_ccb->ccb_h.path->bus->last_reset)) {
 			reset_ccb = xpt_alloc_ccb_nowait();
+			if (reset_ccb == NULL) {
+				request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+				xpt_free_ccb(work_ccb);
+				xpt_done(request_ccb);
+				return;
+			}
 			xpt_setup_ccb(&reset_ccb->ccb_h, request_ccb->ccb_h.path,
 			      CAM_PRIORITY_NONE);
 			reset_ccb->ccb_h.func_code = XPT_RESET_BUS;
@@ -1229,6 +1235,7 @@ ata_scan_bus(struct cam_periph *periph, 
 		    malloc(sizeof(ata_scan_bus_info), M_CAMXPT, M_NOWAIT);
 		if (scan_info == NULL) {
 			request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+			xpt_free_ccb(work_ccb);
 			xpt_done(request_ccb);
 			return;
 		}


More information about the svn-src-all mailing list