usb: gadget: f_fs: fix NULL pointer dereference when there are no strings
authorMichal Nazarewicz <mina86@mina86.com>
Tue, 17 Jun 2014 15:47:41 +0000 (17:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2014 17:51:19 +0000 (10:51 -0700)
commit005564fb1a1d98ae98e720f283e15275e5734562
tree85afdeec4c62c7e34c2a461275e91aa5e8d158c7
parentd539a0515798a3790eaa4a898746fc105be237b0
usb: gadget: f_fs: fix NULL pointer dereference when there are no strings

commit f0688c8b81d2ea239c3fb0b848f623b579238d99 upstream.

If the descriptors do not need any strings and user space sends empty
set of strings, the ffs->stringtabs field remains NULL.  Thus
*ffs->stringtabs in functionfs_bind leads to a NULL pointer
dereferenece.

The bug was introduced by commit [fd7c9a007f: “use usb_string_ids_n()”].

While at it, remove double initialisation of lang local variable in
that function.

ffs->strings_count does not need to be checked in any way since in
the above scenario it will remain zero and usb_string_ids_n() is
a no-operation when colled with 0 argument.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/f_fs.c