]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390/qeth: fix discipline unload after setup error
authorJulian Wiedmann <jwi@linux.ibm.com>
Wed, 26 Sep 2018 16:29:04 +0000 (18:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Sep 2018 16:56:07 +0000 (09:56 -0700)
Device initialization code usually first loads a subdriver
(via qeth_core_load_discipline()), and then runs its setup() callback.
If this fails, it rolls back the load via qeth_core_free_discipline().

qeth_core_free_discipline() expects the options.layer attribute to be
initialized, but on error in setup() that's currently not the case.
Resulting in misbalanced symbol_put() calls.

Fix this by setting options.layer when loading the subdriver.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_core_sys.c
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c

index c3068f680f671e55958a39b0d02d2209cde19933..1fed8f113f4018ad7f90f1e9653b73ce43ae2584 100644 (file)
@@ -5614,6 +5614,7 @@ int qeth_core_load_discipline(struct qeth_card *card,
                return -EINVAL;
        }
 
+       card->options.layer = discipline;
        return 0;
 }
 
@@ -5623,6 +5624,7 @@ void qeth_core_free_discipline(struct qeth_card *card)
                symbol_put(qeth_l2_discipline);
        else
                symbol_put(qeth_l3_discipline);
+       card->options.layer = QETH_DISCIPLINE_UNDETERMINED;
        card->discipline = NULL;
 }
 
index fdb67af811f4992e431f4c6ff90cb97419c6b9fb..970f6c71a66e727cbcb34f801a292cd1d5f5e446 100644 (file)
@@ -432,8 +432,6 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
 
                card->discipline->remove(card->gdev);
                qeth_core_free_discipline(card);
-               card->options.layer = QETH_DISCIPLINE_UNDETERMINED;
-
                free_netdev(card->dev);
                card->dev = ndev;
        }
index afa7a005b21e8f52d43922bfb701130e0a8a9e38..02566af7e23d5d1ca906ff06cf70a431079ec0a5 100644 (file)
@@ -806,7 +806,6 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev)
        }
        INIT_LIST_HEAD(&card->vid_list);
        hash_init(card->mac_htable);
-       card->options.layer = QETH_DISCIPLINE_LAYER2;
        card->info.hwtrap = 0;
        qeth_l2_vnicc_set_defaults(card);
        return 0;
index 552bfad20f851fe1c6b1f85e8fdd35e59a6426c9..2756795f77082f71fd8555ac88fa815b341e2f5a 100644 (file)
@@ -2489,7 +2489,6 @@ static int qeth_l3_probe_device(struct ccwgroup_device *gdev)
        }
        hash_init(card->ip_htable);
        hash_init(card->ip_mc_htable);
-       card->options.layer = QETH_DISCIPLINE_LAYER3;
        card->info.hwtrap = 0;
        return 0;
 }