Index: uspace/lib/ata/src/ata.c
===================================================================
--- uspace/lib/ata/src/ata.c	(revision 0d00e53ee0e707747c5d846467b5eddfa7a0e101)
+++ uspace/lib/ata/src/ata.c	(revision 9e7e1dc54b54c45a22b8d477342affeced0f20fc)
@@ -260,5 +260,6 @@
 		if (rc != EOK) {
 			ata_msg_error(chan, "Unable to remove device %d.", i);
-			break;
+			fibril_mutex_unlock(&chan->lock);
+			return rc;
 		}
 	}
@@ -266,4 +267,5 @@
 	ata_bd_fini_irq(chan);
 	fibril_mutex_unlock(&chan->lock);
+	free(chan);
 
 	return rc;
