Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Oct 2013 16:01:43 +0000 (UTC)
From:      Jim Harris <jimharris@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256155 - head/sys/dev/nvme
Message-ID:  <201310081601.r98G1hp2006228@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jimharris
Date: Tue Oct  8 16:01:43 2013
New Revision: 256155
URL: http://svnweb.freebsd.org/changeset/base/256155

Log:
  Do not leak resources during attach if nvme_ctrlr_construct() or the initial
  controller resets fail.
  
  Sponsored by:	Intel
  Reviewed by:	carl
  Approved by:	re (hrs)
  MFC after:	1 week

Modified:
  head/sys/dev/nvme/nvme.c

Modified: head/sys/dev/nvme/nvme.c
==============================================================================
--- head/sys/dev/nvme/nvme.c	Tue Oct  8 16:00:12 2013	(r256154)
+++ head/sys/dev/nvme/nvme.c	Tue Oct  8 16:01:43 2013	(r256155)
@@ -221,8 +221,10 @@ nvme_attach(device_t dev)
 
 	status = nvme_ctrlr_construct(ctrlr, dev);
 
-	if (status != 0)
+	if (status != 0) {
+		nvme_ctrlr_destruct(ctrlr, dev);
 		return (status);
+	}
 
 	/*
 	 * Reset controller twice to ensure we do a transition from cc.en==1
@@ -230,12 +232,16 @@ nvme_attach(device_t dev)
 	 *  the controller was left in when boot handed off to OS.
 	 */
 	status = nvme_ctrlr_hw_reset(ctrlr);
-	if (status != 0)
+	if (status != 0) {
+		nvme_ctrlr_destruct(ctrlr, dev);
 		return (status);
+	}
 
 	status = nvme_ctrlr_hw_reset(ctrlr);
-	if (status != 0)
+	if (status != 0) {
+		nvme_ctrlr_destruct(ctrlr, dev);
 		return (status);
+	}
 
 	nvme_sysctl_initialize_ctrlr(ctrlr);
 



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