2011/8/18 Michal Nazarewicz <mina86@xxxxxxxxxx>:On Thu, 18 Aug 2011 11:28:46 +0200, Per Forlin wrote:If the allocation of buffhds is done separately in fsg_common_init().
diff --git a/drivers/usb/gadget/f_mass_storage.c
b/drivers/usb/gadget/f_mass_storage.c
index 5b93395..3e546d9 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -363,7 +363,6 @@ struct fsg_common {
struct fsg_buffhd *next_buffhd_to_fill;
struct fsg_buffhd *next_buffhd_to_drain;
- struct fsg_buffhd buffhds[FSG_NUM_BUFFERS];
int cmnd_size;
u8 cmnd[MAX_COMMAND_SIZE];
@@ -407,6 +406,8 @@ struct fsg_common {
char inquiry_string[8 + 16 + 4 + 1];
struct kref ref;
+ /* Must be the last entry */
+ struct fsg_buffhd buffhds[0];
I would rather see it as âstruct fsg_buffhd *buffhds;â since this change
requires both mass_storage.c and multi.c to be changed.
mass_storage.c and multi.c doesn't need to be changed. But it's little
tricky to know whether buffhds should be allocated or not.