Skip to content

Commit 80a9fad

Browse files
Anton Vorontsovdavem330
authored andcommitted
ucc_geth: fix module removal
- uccf should be set to NULL to not double-free memory on subsequent calls; - ind_hash_q and group_hash_q lists should be initialized in the probe() function, instead of struct_init() (called by open()), otherwise there will be an oops if ucc_geth_driver removed prior 'ifconfig ethX up'; - add unregister_netdev(); - reorder geth_remove() steps. Signed-off-by: Anton Vorontsov <[email protected]> Signed-off-by: Jeff Garzik <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f67c627 commit 80a9fad

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

drivers/net/ucc_geth.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,8 +2084,10 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
20842084
if (!ugeth)
20852085
return;
20862086

2087-
if (ugeth->uccf)
2087+
if (ugeth->uccf) {
20882088
ucc_fast_free(ugeth->uccf);
2089+
ugeth->uccf = NULL;
2090+
}
20892091

20902092
if (ugeth->p_thread_data_tx) {
20912093
qe_muram_free(ugeth->thread_dat_tx_offset);
@@ -2305,10 +2307,6 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
23052307
ug_info = ugeth->ug_info;
23062308
uf_info = &ug_info->uf_info;
23072309

2308-
/* Create CQs for hash tables */
2309-
INIT_LIST_HEAD(&ugeth->group_hash_q);
2310-
INIT_LIST_HEAD(&ugeth->ind_hash_q);
2311-
23122310
if (!((uf_info->bd_mem_part == MEM_PART_SYSTEM) ||
23132311
(uf_info->bd_mem_part == MEM_PART_MURAM))) {
23142312
if (netif_msg_probe(ugeth))
@@ -3990,6 +3988,10 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
39903988
ugeth = netdev_priv(dev);
39913989
spin_lock_init(&ugeth->lock);
39923990

3991+
/* Create CQs for hash tables */
3992+
INIT_LIST_HEAD(&ugeth->group_hash_q);
3993+
INIT_LIST_HEAD(&ugeth->ind_hash_q);
3994+
39933995
dev_set_drvdata(device, dev);
39943996

39953997
/* Set the dev->base_addr to the gfar reg region */
@@ -4040,9 +4042,10 @@ static int ucc_geth_remove(struct of_device* ofdev)
40404042
struct net_device *dev = dev_get_drvdata(device);
40414043
struct ucc_geth_private *ugeth = netdev_priv(dev);
40424044

4043-
dev_set_drvdata(device, NULL);
4044-
ucc_geth_memclean(ugeth);
4045+
unregister_netdev(dev);
40454046
free_netdev(dev);
4047+
ucc_geth_memclean(ugeth);
4048+
dev_set_drvdata(device, NULL);
40464049

40474050
return 0;
40484051
}

0 commit comments

Comments
 (0)