Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jun 2010 09:31:13 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r208823 - head/sys/cam/ata
Message-ID:  <201006050931.o559VD5L078232@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006050931.o559VD5L078232>