Skip to content

Commit

Permalink
s390/qeth: unregister netdevice only when registered
Browse files Browse the repository at this point in the history
qeth only registers its netdevice when the qeth device is first set
online. Thus a device that has never been set online will trigger
a WARN ("network todo 'hsi%d' but state 0") in unregister_netdev() when
removed.

Fix this by protecting the unregister step, just like we already protect
against repeated registering of the netdevice.

Fixes: d3d1b20 ("s390/qeth: allocate netdevice early")
Reported-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julian Wiedmann authored and David S. Miller committed Nov 3, 2018
1 parent bd74a7f commit 30356d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions drivers/s390/net/qeth_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,11 @@ struct qeth_trap_id {
/*some helper functions*/
#define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")

static inline bool qeth_netdev_is_registered(struct net_device *dev)
{
return dev->netdev_ops != NULL;
}

static inline void qeth_scrub_qdio_buffer(struct qdio_buffer *buf,
unsigned int elements)
{
Expand Down
5 changes: 3 additions & 2 deletions drivers/s390/net/qeth_l2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)

if (cgdev->state == CCWGROUP_ONLINE)
qeth_l2_set_offline(cgdev);
unregister_netdev(card->dev);
if (qeth_netdev_is_registered(card->dev))
unregister_netdev(card->dev);
}

static const struct ethtool_ops qeth_l2_ethtool_ops = {
Expand Down Expand Up @@ -866,7 +867,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
{
int rc;

if (card->dev->netdev_ops)
if (qeth_netdev_is_registered(card->dev))
return 0;

card->dev->priv_flags |= IFF_UNICAST_FLT;
Expand Down
5 changes: 3 additions & 2 deletions drivers/s390/net/qeth_l3_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
unsigned int headroom;
int rc;

if (card->dev->netdev_ops)
if (qeth_netdev_is_registered(card->dev))
return 0;

if (card->info.type == QETH_CARD_TYPE_OSD ||
Expand Down Expand Up @@ -2465,7 +2465,8 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
if (cgdev->state == CCWGROUP_ONLINE)
qeth_l3_set_offline(cgdev);

unregister_netdev(card->dev);
if (qeth_netdev_is_registered(card->dev))
unregister_netdev(card->dev);
qeth_l3_clear_ip_htable(card, 0);
qeth_l3_clear_ipato_list(card);
}
Expand Down

0 comments on commit 30356d0

Please sign in to comment.