Skip to content

Commit 99c8c16

Browse files
bastien-curutchetkuba-moo
authored andcommitted
net: dsa: microchip: Fix error path in PTP IRQ setup
If request_threaded_irq() fails during the PTP message IRQ setup, the newly created IRQ mapping is never disposed. Indeed, the ksz_ptp_irq_setup()'s error path only frees the mappings that were successfully set up. Dispose the newly created mapping if the associated request_threaded_irq() fails at setup. Cc: stable@vger.kernel.org Fixes: d0b8fec ("net: dsa: microchip: Fix symetry in ksz_ptp_msg_irq_{setup/free}()") Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Link: https://patch.msgid.link/20260309-ksz-ptp-irq-fix-v1-1-757b3b985955@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 20c1be4 commit 99c8c16

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/net/dsa/microchip/ksz_ptp.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ static int ksz_ptp_msg_irq_setup(struct ksz_port *port, u8 n)
11081108
const struct ksz_dev_ops *ops = port->ksz_dev->dev_ops;
11091109
struct ksz_irq *ptpirq = &port->ptpirq;
11101110
struct ksz_ptp_irq *ptpmsg_irq;
1111+
int ret;
11111112

11121113
ptpmsg_irq = &port->ptpmsg_irq[n];
11131114
ptpmsg_irq->num = irq_create_mapping(ptpirq->domain, n);
@@ -1119,9 +1120,13 @@ static int ksz_ptp_msg_irq_setup(struct ksz_port *port, u8 n)
11191120

11201121
strscpy(ptpmsg_irq->name, name[n]);
11211122

1122-
return request_threaded_irq(ptpmsg_irq->num, NULL,
1123-
ksz_ptp_msg_thread_fn, IRQF_ONESHOT,
1124-
ptpmsg_irq->name, ptpmsg_irq);
1123+
ret = request_threaded_irq(ptpmsg_irq->num, NULL,
1124+
ksz_ptp_msg_thread_fn, IRQF_ONESHOT,
1125+
ptpmsg_irq->name, ptpmsg_irq);
1126+
if (ret)
1127+
irq_dispose_mapping(ptpmsg_irq->num);
1128+
1129+
return ret;
11251130
}
11261131

11271132
int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)

0 commit comments

Comments
 (0)