mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
net: gianfar: dispose irq mappings on probe failure and device removal
irq_of_parse_and_map() creates irqdomain mappings that should be balanced with irq_dispose_mapping(). The driver never called irq_dispose_mapping(), leaking mappings on probe failure and device removal. Fix by adding irq_dispose_mapping() in free_gfar_dev() and expanding its loop from priv->num_grps to MAXGROUPS so the error path also catches partially-initialized groups. All irqinfo pointers are pre-initialized to NULL in gfar_of_init(), making the NULL-guarded walk in free_gfar_dev() safe for every scenario. gfar_parse_group() itself is left as a simple parse function with no resource management; cleanup is centralized in the caller's error path. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260626225228.427392-1-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
895bad9cc4
commit
cef9d68040
|
|
@ -469,10 +469,13 @@ static void free_gfar_dev(struct gfar_private *priv)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < priv->num_grps; i++)
|
||||
for (i = 0; i < MAXGROUPS; i++)
|
||||
for (j = 0; j < GFAR_NUM_IRQS; j++) {
|
||||
kfree(priv->gfargrp[i].irqinfo[j]);
|
||||
priv->gfargrp[i].irqinfo[j] = NULL;
|
||||
if (priv->gfargrp[i].irqinfo[j]) {
|
||||
irq_dispose_mapping(priv->gfargrp[i].irqinfo[j]->irq);
|
||||
kfree(priv->gfargrp[i].irqinfo[j]);
|
||||
priv->gfargrp[i].irqinfo[j] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free_netdev(priv->ndev);
|
||||
|
|
@ -616,7 +619,7 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)
|
|||
static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
|
||||
{
|
||||
const char *model;
|
||||
int err = 0, i;
|
||||
int err = 0, i, j;
|
||||
phy_interface_t interface;
|
||||
struct net_device *dev = NULL;
|
||||
struct gfar_private *priv = NULL;
|
||||
|
|
@ -702,8 +705,11 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
|
|||
priv->rx_list.count = 0;
|
||||
mutex_init(&priv->rx_queue_access);
|
||||
|
||||
for (i = 0; i < MAXGROUPS; i++)
|
||||
for (i = 0; i < MAXGROUPS; i++) {
|
||||
priv->gfargrp[i].regs = NULL;
|
||||
for (j = 0; j < GFAR_NUM_IRQS; j++)
|
||||
priv->gfargrp[i].irqinfo[j] = NULL;
|
||||
}
|
||||
|
||||
/* Parse and initialize group specific information */
|
||||
if (priv->mode == MQ_MG_MODE) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user