Index: uspace/lib/ata/src/ata.c
===================================================================
--- uspace/lib/ata/src/ata.c	(revision 7cec2164e3bdb4c02f6ae514bc16e9c7c48be618)
+++ uspace/lib/ata/src/ata.c	(revision 743f2cdd361af5078f5d096158a45c0e7c4ad059)
@@ -179,4 +179,8 @@
 	int n_disks;
 	bool irq_inited = false;
+	bool dev_added[MAX_DEVICES];
+
+	for (i = 0; i < MAX_DEVICES; i++)
+		dev_added[i] = false;
 
 	ata_msg_debug(chan, "ata_channel_initialize()");
@@ -212,4 +216,5 @@
 			goto error;
 		}
+		dev_added[i] = true;
 		++n_disks;
 	}
@@ -224,6 +229,10 @@
 error:
 	for (i = 0; i < MAX_DEVICES; i++) {
-		if (ata_device_add(&chan->device[i]) != EOK) {
-			ata_msg_error(chan, "Unable to remove device %d.", i);
+		if (dev_added[i]) {
+			rc = ata_device_remove(&chan->device[i]);
+			if (rc != EOK) {
+				ata_msg_error(chan,
+				    "Unable to remove device %d.", i);
+			}
 		}
 	}
