Opened 13 years ago

Closed 13 years ago

#376 closed defect (fixed)

Crash in usbmast during boot

Reported by: Jakub Jermář Owned by:
Priority: major Milestone: 0.5.0
Component: helenos/drv/usbmast Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

As of mainline,1234, usbmast driver crashes on my desktop computer (ia32, UP) during boot as follows:

[usbmast] info: Initializing `mass-storage0`.
[usbmast] info: Mass storage `mass-storage0` LUN 0: USB SD Reader by Generic rev. 1.00 is Direct-
[usbmast] ERROR: Inquiry transport failed, device mass-storage0: Unknown error code -265.
[usbmast] ERROR: Read Capacity (10) transport failed, device mass-storage0: Unknown error code -26
[usbmast] WARN: Failed to read cpapacity, device `mass-storage0`: Unknown error code -265.
Assertion failed (head->size == foot->size) in file "generic/malloc.c", line 255.
Assertion failed (head->size == foot->size) in file "generic/malloc.c", line 255.

And the following stack-trace (abbreviated) is printed:

free+375
driver_connection+1113
connection_fibril+82
fibril_main+25

/log/usbmast repeats the info:, ERROR: and WARN: lines above, interleaved by:

[usbmast]:  Bulk in endpoint: 2 [64B].
[usbmast]: Bulk out endpoint: 1 [64B].
[usbmast]: Get LUN count...
[usbmast]: Inquire...

Change History (3)

comment:1 by Jakub Jermář, 13 years ago

Ok, I think the problem might be that usbmast_fun_create() sets both device and function driver data to point to the same buffer, i.e. mfun. This buffer is later freed by both DDF delete_device() and delete_function(). The following patch seems to fix the crash of usbmast during system startup. Later, after plugging in a flash disk, the disk is recognized by the driver and l0 (for lun0) child node is created. I am unfortunately not clever enough to figure out how to specify the new block device e.g. to the bdd builtin or the mount builtin.

Jiri, do you think the following patch is appropriate?

=== modified file 'uspace/drv/bus/usb/usbmast/main.c'
--- uspace/drv/bus/usb/usbmast/main.c	2011-08-29 23:00:12 +0000
+++ uspace/drv/bus/usb/usbmast/main.c	2011-10-01 23:51:45 +0000
@@ -160,7 +160,7 @@
 	free(fun_name);
 
 	/* Allocate soft state */
-	mfun = ddf_dev_data_alloc(mdev->ddf_dev, sizeof(usbmast_fun_t));
+	mfun = ddf_fun_data_alloc(fun, sizeof(usbmast_fun_t));
 	if (mfun == NULL) {
 		usb_log_error("Failed allocating softstate.\n");
 		rc = ENOMEM;
@@ -174,7 +174,6 @@
 
 	/* Set up a connection handler. */
 	fun->conn_handler = usbmast_bd_connection;
-	fun->driver_data = mfun;
 
 	usb_log_debug("Inquire...\n");
 	usbmast_inquiry_data_t inquiry;

comment:2 by Jiri Svoboda, 13 years ago

Perfect. Commited (mainline,1258), thanks.

comment:3 by Jiri Svoboda, 13 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.