From: Wentao Liang <vulab@iscas.ac.cn>
To: olteanv@gmail.com, andrew@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] net: dsa: sja1105: fix refcount leak in sja1105_setup_tc_taprio()
Date: Tue, 9 Jun 2026 07:40:02 +0000 [thread overview]
Message-ID: <20260609074002.204113-1-vulab@iscas.ac.cn> (raw)
In sja1105_setup_tc_taprio(), taprio_offload_get() acquires a
reference on the new offload and stores it in
tas_data->offload[port]. If sja1105_init_scheduling() or
sja1105_static_config_reload() later fails, the function returns
without releasing the reference via taprio_offload_free(). The
stored pointer is thus leaked, as the driver will not clean it up
unless a subsequent TAPRIO_CMD_DESTROY is received, which may
never happen.
Fix the leak by calling taprio_offload_free() and resetting
tas_data->offload[port] to NULL on both error paths.
Cc: stable@vger.kernel.org
Fixes: 317ab5b86c8e ("net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/dsa/sja1105/sja1105_tas.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_tas.c b/drivers/net/dsa/sja1105/sja1105_tas.c
index e47967b12d5d..96cb5aa04910 100644
--- a/drivers/net/dsa/sja1105/sja1105_tas.c
+++ b/drivers/net/dsa/sja1105/sja1105_tas.c
@@ -575,10 +575,18 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
tas_data->offload[port] = taprio_offload_get(admin);
rc = sja1105_init_scheduling(priv);
- if (rc < 0)
+ if (rc < 0) {
+ taprio_offload_free(tas_data->offload[port]);
+ tas_data->offload[port] = NULL;
return rc;
+ }
- return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
+ rc = sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
+ if (rc < 0) {
+ taprio_offload_free(tas_data->offload[port]);
+ tas_data->offload[port] = NULL;
+ }
+ return rc;
}
static int sja1105_tas_check_running(struct sja1105_private *priv)
--
2.34.1
next reply other threads:[~2026-06-09 7:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 7:40 Wentao Liang [this message]
2026-06-11 14:01 ` Simon Horman
2026-06-13 8:41 ` Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609074002.204113-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®