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: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Coiby Xu <coxu@redhat.com> Link: https://lore.kernel.org/r/20210324010002.109846-1-coxu@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9c15db92a8
commit
d8827ae8e2
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue