Index: uspace/drv/bus/usb/usbmast/main.c
===================================================================
--- uspace/drv/bus/usb/usbmast/main.c	(revision a92ce4ef5f647f9fe5fe2f33d2ca9381ad52b046)
+++ uspace/drv/bus/usb/usbmast/main.c	(revision 87037cc964953580eab1f30e5a171547c9e01cb3)
@@ -112,7 +112,13 @@
 
 	usb_log_debug("Get LUN count...\n");
-	mdev->luns = usb_masstor_get_lun_count(mdev);
-
-	for (i = 0; i < mdev->luns; i++) {
+	mdev->lun_count = usb_masstor_get_lun_count(mdev);
+	mdev->luns = calloc(mdev->lun_count, sizeof(ddf_fun_t*));
+	if (mdev->luns == NULL) {
+		rc = ENOMEM;
+		usb_log_error("Failed allocating luns table.\n");
+		goto error;
+	}
+
+	for (i = 0; i < mdev->lun_count; i++) {
 		rc = usbmast_fun_create(mdev, i);
 		if (rc != EOK)
@@ -162,4 +168,5 @@
 	}
 
+	mfun->ddf_fun = fun;
 	mfun->mdev = mdev;
 	mfun->lun = lun;
@@ -212,4 +219,5 @@
 
 	free(fun_name);
+	mdev->luns[lun] = fun;
 
 	return EOK;
Index: uspace/drv/bus/usb/usbmast/usbmast.h
===================================================================
--- uspace/drv/bus/usb/usbmast/usbmast.h	(revision a92ce4ef5f647f9fe5fe2f33d2ca9381ad52b046)
+++ uspace/drv/bus/usb/usbmast/usbmast.h	(revision 87037cc964953580eab1f30e5a171547c9e01cb3)
@@ -41,5 +41,5 @@
 
 /** Mass storage device. */
-typedef struct {
+typedef struct usbmast_dev {
 	/** DDF device */
 	ddf_dev_t *ddf_dev;
@@ -47,6 +47,9 @@
 	usb_device_t *usb_dev;
 	/** Number of LUNs */
-	unsigned luns;
+	unsigned lun_count;
+	/** LUN functions */
+	ddf_fun_t **luns;
 } usbmast_dev_t;
+
 
 /** Mass storage function.
