Index: uspace/lib/ata/src/ata.c
===================================================================
--- uspace/lib/ata/src/ata.c	(revision c4ed9fac928b1683c3ccc7d35d520ec9962fe18a)
+++ uspace/lib/ata/src/ata.c	(revision 49aaa0e35a10f53802af5c8cb22cd8f46f1230bb)
@@ -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);
+			}
 		}
 	}
