Commit d8827ae8 authored by Coiby Xu's avatar Coiby Xu Committed by Greg Kroah-Hartman

staging: qlge: deal with the case that devlink_health_reporter_create fails

devlink_health_reporter_create may fail. In that case, do the cleanup
work.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarCoiby Xu <coxu@redhat.com>
Link: https://lore.kernel.org/r/20210324010002.109846-1-coxu@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9c15db92
......@@ -148,16 +148,20 @@ static const struct devlink_health_reporter_ops qlge_reporter_ops = {
.dump = qlge_reporter_coredump,
};
void qlge_health_create_reporters(struct qlge_adapter *priv)
long qlge_health_create_reporters(struct qlge_adapter *priv)
{
struct devlink *devlink;
long err = 0;
devlink = priv_to_devlink(priv);
priv->reporter =
devlink_health_reporter_create(devlink, &qlge_reporter_ops,
0, priv);
if (IS_ERR(priv->reporter))
if (IS_ERR(priv->reporter)) {
err = PTR_ERR(priv->reporter);
netdev_warn(priv->ndev,
"Failed to create reporter, err = %ld\n",
PTR_ERR(priv->reporter));
err);
}
return err;
}
......@@ -4,6 +4,6 @@
#include <net/devlink.h>
void qlge_health_create_reporters(struct qlge_adapter *priv);
long qlge_health_create_reporters(struct qlge_adapter *priv);
#endif /* QLGE_DEVLINK_H */
......@@ -4621,7 +4621,11 @@ static int qlge_probe(struct pci_dev *pdev,
if (err)
goto netdev_free;
qlge_health_create_reporters(qdev);
err = qlge_health_create_reporters(qdev);
if (err)
goto devlink_unregister;
/* Start up the timer to trigger EEH if
* the bus goes dead
*/
......@@ -4633,6 +4637,8 @@ static int qlge_probe(struct pci_dev *pdev,
cards_found++;
return 0;
devlink_unregister:
devlink_unregister(devlink);
netdev_free:
free_netdev(ndev);
devlink_free:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment