From: Thorsten Blum <thorsten.blum@linux.dev>
To: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Tyrel Datwyler <tyreld@linux.ibm.com>,
Mahesh Salgaonkar <mahesh@linux.ibm.com>,
Haren Myneni <haren@linux.ibm.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] powerpc/rtasd: Use struct_size() to simplify log_rtas_len()
Date: Fri, 26 Jun 2026 20:47:49 +0200 [thread overview]
Message-ID: <20260626184750.166642-3-thorsten.blum@linux.dev> (raw)
Now that struct rtas_error_log uses a flexible array member for the
extended log buffer, use struct_size() to calculate the total RTAS error
log size and avoid using the hard-coded header size of 8 bytes.
Use min() to replace the open-coded implementation while at it.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/powerpc/kernel/rtasd.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index 6336ec9aedd0..fd40864bdb70 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -10,6 +10,7 @@
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/of.h>
+#include <linux/overflow.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
@@ -160,25 +161,17 @@ static void printk_log_rtas(char *buf, int len)
static int log_rtas_len(char * buf)
{
- int len;
+ size_t len;
struct rtas_error_log *err;
- uint32_t extended_log_length;
+ u32 extended_log_length;
- /* rtas fixed header */
- len = 8;
err = (struct rtas_error_log *)buf;
- extended_log_length = rtas_error_extended_log_length(err);
- if (rtas_error_extended(err) && extended_log_length) {
-
- /* extended header */
- len += extended_log_length;
- }
+ extended_log_length = rtas_error_extended(err) ? rtas_error_extended_log_length(err) : 0;
+ len = struct_size(err, buffer, extended_log_length);
if (rtas_error_log_max == 0)
rtas_error_log_max = rtas_get_error_log_max();
-
- if (len > rtas_error_log_max)
- len = rtas_error_log_max;
+ len = min(len, rtas_error_log_max);
return len;
}
next reply other threads:[~2026-06-26 18:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 18:47 Thorsten Blum [this message]
2026-06-26 18:47 ` [PATCH 2/2] powerpc/pseries/ras: Use struct_size() to simplify fwnmi_get_errinfo() Thorsten Blum
2026-06-26 19:25 ` Thorsten Blum
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=20260626184750.166642-3-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=chleroy@kernel.org \
--cc=haren@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=tyreld@linux.ibm.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