]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
usb: gadget: fsl_udc_core: check allocation return value and cleanup on failure
authorNicholas Mc Guire <hofrat@osadl.org>
Thu, 30 Aug 2018 10:16:58 +0000 (12:16 +0200)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commitb6aee2848d4566cc278564c9e2f944611411a464
tree2f4ddd0e3094a86a621f230bb9277a18adc11e4a
parent793652480a1516c3b02c51e90b0eb009c8bbe7b0
usb: gadget: fsl_udc_core: check allocation return value and cleanup on failure

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 4ab2b48c98f2ec9712452d520a381917f91ac3d2 ]

The allocation with fsl_alloc_request() and kmalloc() were unchecked
fixed this up with a NULL check and appropriate cleanup.

Additionally udc->ep_qh_size was reset to 0 on failure of allocation.
Similar udc->phy_mode is initially 0 (as udc_controller was
allocated with kzalloc in fsl_udc_probe()) so reset it to 0 as well
so that this function is side-effect free on failure. Not clear if
this is necessary or sensible as fsl_udc_release() probably can not
be called if fsl_udc_probe() failed - but it should not hurt.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: b504882da5 ("USB: add Freescale high-speed USB SOC device controller driver")
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/usb/gadget/udc/fsl_udc_core.c