usb: gadget: f_hid: tidy error handling in hidg_alloc
authorJohn Keeping <john@metanate.com>
Tue, 22 Nov 2022 12:35:23 +0000 (12:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2022 07:56:09 +0000 (08:56 +0100)
commit944fe915d00d3cb1bacb1e77cabfb6dc82e6f8b8
treee340f46d18fbc8894047252e3cdcc2389496c3ae
parent70a3288a7586526315105c699b687d78cd32559a
usb: gadget: f_hid: tidy error handling in hidg_alloc

Unify error handling at the end of the function, reducing the risk of
missing something on one of the error paths.

Moving the increment of opts->refcnt later means there is no need to
decrement it on the error path and is safe as this is guarded by
opts->lock which is held for this entire section.

Tested-by: Lee Jones <lee@kernel.org>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Lee Jones <lee@kernel.org>
Signed-off-by: John Keeping <john@metanate.com>
Link: https://lore.kernel.org/r/20221122123523.3068034-4-john@metanate.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_hid.c