From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH] intel_th: msu-sink: reduce priv allocation to 1
Date: Thu, 19 Mar 2026 17:56:26 -0700 [thread overview]
Message-ID: <20260320005626.30660-1-rosenp@gmail.com> (raw)
Simpler to use a flexible array member and kzalloc_flex.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/hwtracing/intel_th/msu-sink.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c
index b809a7f805a9..608d0f3d9e1a 100644
--- a/drivers/hwtracing/intel_th/msu-sink.c
+++ b/drivers/hwtracing/intel_th/msu-sink.c
@@ -15,24 +15,18 @@
struct msu_sink_private {
struct device *dev;
- struct sg_table **sgts;
unsigned int nr_sgts;
+ struct sg_table *sgts[];
};
static void *msu_sink_assign(struct device *dev, int *mode)
{
struct msu_sink_private *priv;
- priv = kzalloc_obj(*priv);
+ priv = kzalloc_flex(*priv, sgts, MAX_SGTS, GFP_KERNEL);
if (!priv)
return NULL;
- priv->sgts = kcalloc(MAX_SGTS, sizeof(void *), GFP_KERNEL);
- if (!priv->sgts) {
- kfree(priv);
- return NULL;
- }
-
priv->dev = dev;
*mode = MSC_MODE_MULTI;
@@ -43,7 +37,6 @@ static void msu_sink_unassign(void *data)
{
struct msu_sink_private *priv = data;
- kfree(priv->sgts);
kfree(priv);
}
--
2.53.0
reply other threads:[~2026-03-20 0:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260320005626.30660-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@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®