Commit 57f63faf authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: only set endpoint netdev pointer when in use

In ipa_modem_start(), we set endpoint netdev pointers before the
network device is registered.  If registration fails, we don't undo
those assignments.  Instead, wait to assign the netdev pointer until
after registration succeeds.

Set these endpoint netdev pointers to NULL in ipa_modem_stop()
before unregistering the network device.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 49e76a41
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
* Copyright (C) 2018-2020 Linaro Ltd. * Copyright (C) 2018-2021 Linaro Ltd.
*/ */
#include <linux/errno.h> #include <linux/errno.h>
...@@ -213,18 +213,18 @@ int ipa_modem_start(struct ipa *ipa) ...@@ -213,18 +213,18 @@ int ipa_modem_start(struct ipa *ipa)
goto out_set_state; goto out_set_state;
} }
ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev;
ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev;
SET_NETDEV_DEV(netdev, &ipa->pdev->dev); SET_NETDEV_DEV(netdev, &ipa->pdev->dev);
priv = netdev_priv(netdev); priv = netdev_priv(netdev);
priv->ipa = ipa; priv->ipa = ipa;
ret = register_netdev(netdev); ret = register_netdev(netdev);
if (ret) if (!ret) {
free_netdev(netdev);
else
ipa->modem_netdev = netdev; ipa->modem_netdev = netdev;
ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev;
ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev;
} else {
free_netdev(netdev);
}
out_set_state: out_set_state:
if (ret) if (ret)
...@@ -263,6 +263,8 @@ int ipa_modem_stop(struct ipa *ipa) ...@@ -263,6 +263,8 @@ int ipa_modem_stop(struct ipa *ipa)
if (ret) if (ret)
goto out_set_state; goto out_set_state;
ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = NULL;
ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = NULL;
ipa->modem_netdev = NULL; ipa->modem_netdev = NULL;
unregister_netdev(netdev); unregister_netdev(netdev);
free_netdev(netdev); free_netdev(netdev);
......
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