diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2014-06-17 11:47:41 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-06-19 11:06:47 -0400 |
commit | f0688c8b81d2ea239c3fb0b848f623b579238d99 (patch) | |
tree | 4a5ffe092c8c190a23de81b98e1db5a80ee094eb /drivers/usb | |
parent | 82363cf2eeafeea6ba88849f5e2febdc8a05943f (diff) |
usb: gadget: f_fs: fix NULL pointer dereference when there are no strings
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.
Cc: <stable@vger.kernel.org> # v2.6.36+
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/f_fs.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 74202d67f911..8598c27c7d43 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -1483,11 +1483,13 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | |||
1483 | ffs->ep0req->context = ffs; | 1483 | ffs->ep0req->context = ffs; |
1484 | 1484 | ||
1485 | lang = ffs->stringtabs; | 1485 | lang = ffs->stringtabs; |
1486 | for (lang = ffs->stringtabs; *lang; ++lang) { | 1486 | if (lang) { |
1487 | struct usb_string *str = (*lang)->strings; | 1487 | for (; *lang; ++lang) { |
1488 | int id = first_id; | 1488 | struct usb_string *str = (*lang)->strings; |
1489 | for (; str->s; ++id, ++str) | 1489 | int id = first_id; |
1490 | str->id = id; | 1490 | for (; str->s; ++id, ++str) |
1491 | str->id = id; | ||
1492 | } | ||
1491 | } | 1493 | } |
1492 | 1494 | ||
1493 | ffs->gadget = cdev->gadget; | 1495 | ffs->gadget = cdev->gadget; |