Skip to content

Commit bc0151c

Browse files
committed
Merge branch 'net-bcmasp-fix-issues-during-driver-unbind'
Justin Chen says: ==================== net: bcmasp: Fix issues during driver unbind Fix two issues when we unbind the driver. We hit a double free of the WoL irq and a double disable of the clk. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 7a4fc5c + 27dfe90 commit bc0151c

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

  • drivers/net/ethernet/broadcom/asp2

drivers/net/ethernet/broadcom/asp2/bcmasp.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,6 @@ void bcmasp_enable_wol(struct bcmasp_intf *intf, bool en)
11521152
}
11531153
}
11541154

1155-
static void bcmasp_wol_irq_destroy(struct bcmasp_priv *priv)
1156-
{
1157-
if (priv->wol_irq > 0)
1158-
free_irq(priv->wol_irq, priv);
1159-
}
1160-
11611155
static void bcmasp_eee_fixup(struct bcmasp_intf *intf, bool en)
11621156
{
11631157
u32 reg, phy_lpi_overwrite;
@@ -1255,7 +1249,7 @@ static int bcmasp_probe(struct platform_device *pdev)
12551249
if (priv->irq <= 0)
12561250
return -EINVAL;
12571251

1258-
priv->clk = devm_clk_get_optional_enabled(dev, "sw_asp");
1252+
priv->clk = devm_clk_get_optional(dev, "sw_asp");
12591253
if (IS_ERR(priv->clk))
12601254
return dev_err_probe(dev, PTR_ERR(priv->clk),
12611255
"failed to request clock\n");
@@ -1283,6 +1277,10 @@ static int bcmasp_probe(struct platform_device *pdev)
12831277

12841278
bcmasp_set_pdata(priv, pdata);
12851279

1280+
ret = clk_prepare_enable(priv->clk);
1281+
if (ret)
1282+
return dev_err_probe(dev, ret, "failed to start clock\n");
1283+
12861284
/* Enable all clocks to ensure successful probing */
12871285
bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);
12881286

@@ -1294,8 +1292,10 @@ static int bcmasp_probe(struct platform_device *pdev)
12941292

12951293
ret = devm_request_irq(&pdev->dev, priv->irq, bcmasp_isr, 0,
12961294
pdev->name, priv);
1297-
if (ret)
1298-
return dev_err_probe(dev, ret, "failed to request ASP interrupt: %d", ret);
1295+
if (ret) {
1296+
dev_err(dev, "Failed to request ASP interrupt: %d", ret);
1297+
goto err_clock_disable;
1298+
}
12991299

13001300
/* Register mdio child nodes */
13011301
of_platform_populate(dev->of_node, bcmasp_mdio_of_match, NULL, dev);
@@ -1307,13 +1307,17 @@ static int bcmasp_probe(struct platform_device *pdev)
13071307

13081308
priv->mda_filters = devm_kcalloc(dev, priv->num_mda_filters,
13091309
sizeof(*priv->mda_filters), GFP_KERNEL);
1310-
if (!priv->mda_filters)
1311-
return -ENOMEM;
1310+
if (!priv->mda_filters) {
1311+
ret = -ENOMEM;
1312+
goto err_clock_disable;
1313+
}
13121314

13131315
priv->net_filters = devm_kcalloc(dev, priv->num_net_filters,
13141316
sizeof(*priv->net_filters), GFP_KERNEL);
1315-
if (!priv->net_filters)
1316-
return -ENOMEM;
1317+
if (!priv->net_filters) {
1318+
ret = -ENOMEM;
1319+
goto err_clock_disable;
1320+
}
13171321

13181322
bcmasp_core_init_filters(priv);
13191323

@@ -1322,7 +1326,8 @@ static int bcmasp_probe(struct platform_device *pdev)
13221326
ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
13231327
if (!ports_node) {
13241328
dev_warn(dev, "No ports found\n");
1325-
return -EINVAL;
1329+
ret = -EINVAL;
1330+
goto err_clock_disable;
13261331
}
13271332

13281333
i = 0;
@@ -1344,8 +1349,6 @@ static int bcmasp_probe(struct platform_device *pdev)
13441349
*/
13451350
bcmasp_core_clock_set(priv, 0, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE);
13461351

1347-
clk_disable_unprepare(priv->clk);
1348-
13491352
/* Now do the registration of the network ports which will take care
13501353
* of managing the clock properly.
13511354
*/
@@ -1358,13 +1361,16 @@ static int bcmasp_probe(struct platform_device *pdev)
13581361
count++;
13591362
}
13601363

1364+
clk_disable_unprepare(priv->clk);
1365+
13611366
dev_info(dev, "Initialized %d port(s)\n", count);
13621367

13631368
return ret;
13641369

13651370
err_cleanup:
1366-
bcmasp_wol_irq_destroy(priv);
13671371
bcmasp_remove_intfs(priv);
1372+
err_clock_disable:
1373+
clk_disable_unprepare(priv->clk);
13681374

13691375
return ret;
13701376
}
@@ -1376,7 +1382,6 @@ static void bcmasp_remove(struct platform_device *pdev)
13761382
if (!priv)
13771383
return;
13781384

1379-
bcmasp_wol_irq_destroy(priv);
13801385
bcmasp_remove_intfs(priv);
13811386
}
13821387

0 commit comments

Comments
 (0)