
Hi Jeroen,
Since the struct fsg_common is calloced, reset it completely with zero's when reused. While at it, make checkpatch happy.
cc: Lukasz Majewski l.majewski@samsung.com cc: Piotr Wilczek p.wilczek@samsung.com cc: Kyungmin Park kyungmin.park@samsung.com cc: Marek Vasut marek.vasut@gmail.com Signed-off-by: Jeroen Hofstee jeroen@myspectrum.nl
drivers/usb/gadget/f_mass_storage.c:2470:28: warning: 'memset' call operates on objects of type 'struct fsg_common' while the size is based on a different type 'struct fsg_common *' [-Wsizeof-pointer-memaccess] memset(common, 0, sizeof common);
Note: There is another warning worth mentioning, but I don't know what the correct behaviour should be.
drivers/usb/gadget/f_mass_storage.c:1153:6: warning: variable 'sdinfo' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (!curlun) { /* Unsupported LUNs are okay */ ^~~~~~~ drivers/usb/gadget/f_mass_storage.c:1168:21: note: uninitialized use occurs here put_unaligned_be32(sdinfo, &buf[3]); /* Sense information */ --- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 6374bb9..f274d96 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2462,12 +2462,12 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, /* Allocate? */ if (!common) {
common = calloc(sizeof *common, 1);
if (!common) return ERR_PTR(-ENOMEM); common->free_storage_on_release = 1; } else {common = calloc(sizeof(*common), 1);
memset(common, 0, sizeof common);
common->free_storage_on_release = 0; }memset(common, 0, sizeof(*common));
Acked-by: Lukasz Majewski l.majewski@samsung.com