Skip to content

Commit

Permalink
usb/max3421: fix return error code in max3421_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit 5a56934 ]

retval may be reassigned to 0 after max3421_of_vbus_en_pin(),
if allocate memory failed after this, max3421_probe() cann't
return ENOMEM, fix this by moving assign retval afther max3421_probe().

Fixes: 721fdc8 ("usb: max3421: Add devicetree support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20201117061500.3454223-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed Dec 30, 2020
1 parent e6405aa commit 5df0455
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/host/max3421-hcd.c
Expand Up @@ -1847,7 +1847,7 @@ max3421_probe(struct spi_device *spi)
struct max3421_hcd *max3421_hcd;
struct usb_hcd *hcd = NULL;
struct max3421_hcd_platform_data *pdata = NULL;
int retval = -ENOMEM;
int retval;

if (spi_setup(spi) < 0) {
dev_err(&spi->dev, "Unable to setup SPI bus");
Expand Down Expand Up @@ -1889,6 +1889,7 @@ max3421_probe(struct spi_device *spi)
goto error;
}

retval = -ENOMEM;
hcd = usb_create_hcd(&max3421_hcd_desc, &spi->dev,
dev_name(&spi->dev));
if (!hcd) {
Expand Down

0 comments on commit 5df0455

Please sign in to comment.