From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>, Maor Gottlieb <maorg@mellanox.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH rdma-next 2/3] RDMA/core: Free unpublished port statistics after initial-read failure
Date: Thu, 15 Oct 2026 14:59:01 +0300 [thread overview]
Message-ID: <20261015-ib-core-fixes-v1-2-60f6da3ddec3@nvidia.com> (raw)
In-Reply-To: <20261015-ib-core-fixes-v1-0-60f6da3ddec3@nvidia.com>
From: Leon Romanovsky <leonro@nvidia.com>
An initial port counter read can fail after allocating its statistics
buffer and wrapper. Free these both allocations.
Fixes: 467f432a521a ("RDMA/core: Split port and device counter sysfs attributes")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/core/sysfs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 69df8b703cbd..4cd861b5d953 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -996,8 +996,8 @@ static int setup_hw_port_stats(struct ib_port *port,
data->stats->num_counters);
if (ret != data->stats->num_counters) {
if (WARN_ON(ret >= 0))
- return -EINVAL;
- return ret;
+ ret = -EINVAL;
+ goto err_free_data;
}
data->stats->timestamp = jiffies;
@@ -1031,6 +1031,11 @@ static int setup_hw_port_stats(struct ib_port *port,
port->hw_stats_data = data;
return 0;
+
+err_free_data:
+ rdma_free_hw_stats_struct(data->stats);
+ kfree(data);
+ return ret;
}
struct rdma_hw_stats *ib_get_hw_stats_port(struct ib_device *ibdev,
--
2.55.0
next prev parent reply other threads:[~2026-10-15 11:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:58 [PATCH rdma-next 0/3] Various core fixes spotted by LLMs Leon Romanovsky
2026-10-15 11:59 ` [PATCH rdma-next 1/3] RDMA/core: Preserve the selected source GID on failed AH modification Leon Romanovsky
2026-10-15 11:59 ` Leon Romanovsky [this message]
2026-10-15 12:54 ` [PATCH rdma-next 2/3] RDMA/core: Free unpublished port statistics after initial-read failure Kalesh Anakkur Purayil
2026-10-15 11:59 ` [PATCH rdma-next 3/3] RDMA/core: Reject LAG selection when source MAC lookup fails Leon Romanovsky
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=20261015-ib-core-fixes-v1-2-60f6da3ddec3@nvidia.com \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@mellanox.com \
/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®