usb: misc: eud: Fix an error handling path in eud_probe()

It is odd to call devm_add_action_or_reset() before calling the function
that should be undone.

Either, the "_or_reset" part should be omitted, or the action should be
recorded after the resources have been allocated.

Switch the order of devm_add_action_or_reset() and usb_role_switch_get().

Fixes: 9a1bf58ccd ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/362908699275ecec078381b42d87c817c6965fc6.1648979948.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Christophe JAILLET 2022-04-03 11:59:15 +02:00 committed by Greg Kroah-Hartman
parent 0543e4e885
commit 929b22e669

View file

@ -186,16 +186,16 @@ static int eud_probe(struct platform_device *pdev)
chip->dev = &pdev->dev;
ret = devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip);
if (ret)
return dev_err_probe(chip->dev, ret,
"failed to add role switch release action\n");
chip->role_sw = usb_role_switch_get(&pdev->dev);
if (IS_ERR(chip->role_sw))
return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
"failed to get role switch\n");
ret = devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip);
if (ret)
return dev_err_probe(chip->dev, ret,
"failed to add role switch release action\n");
chip->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(chip->base))
return PTR_ERR(chip->base);