usb: gadget: f_hid: fix: Move IN request allocation to set_alt()
authorKrzysztof Opasiak <kopasiak90@gmail.com>
Tue, 24 Jan 2017 02:27:24 +0000 (03:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Mar 2018 10:00:27 +0000 (11:00 +0100)
commit8dd5c0c47332c67a04830e3842d4d6282f1824fd
tree852168d10c590c45c37227c013a217eacaf67687
parent805cbd500ee258f8c8e5c0c709389fffd70994eb
usb: gadget: f_hid: fix: Move IN request allocation to set_alt()

commit 749494b6bdbbaf0899aa1c62a1ad74cd747bce47 upstream.

Since commit: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()")
we cannot allocate any requests in bind() as we check if we should
align request buffer based on endpoint descriptor which is assigned
in set_alt().

Allocating request in bind() function causes a NULL pointer
dereference.

This commit moves allocation of IN request from bind() to set_alt()
to prevent this issue.

Fixes: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()")
Cc: stable@vger.kernel.org
Tested-by: David Lechner <david@lechnology.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_hid.c