diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2026-06-27 12:47:31 +0200 |
|---|---|---|
| committer | Madhavan Srinivasan <maddy@linux.ibm.com> | 2026-07-31 17:02:07 +0530 |
| commit | 351496d6aea664f25cbd6411bf5567210328e419 (patch) | |
| tree | ab3f6dbedfcd3c28fd7ffd604df5f457506b5bce | |
| parent | 6a7f74525a9964ef3228f6e1d1af261e92964987 (diff) | |
| download | linux-351496d6aea664f25cbd6411bf5567210328e419.tar.gz linux-351496d6aea664f25cbd6411bf5567210328e419.zip | |
powerpc/pseries/ras: Use struct_size() to simplify fwnmi_get_errinfo()
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.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260627104730.276858-4-thorsten.blum@linux.dev
| -rw-r--r-- | arch/powerpc/platforms/pseries/ras.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index adafd593d9d3..7b8713bdd978 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -7,6 +7,7 @@ #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/of.h> +#include <linux/overflow.h> #include <linux/fs.h> #include <linux/reboot.h> #include <linux/irq_work.h> @@ -440,6 +441,8 @@ static __be64 *fwnmi_get_savep(struct pt_regs *regs) static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) { struct rtas_error_log *h; + u32 extended_log_length; + size_t len; __be64 *savep; savep = fwnmi_get_savep(regs); @@ -449,17 +452,12 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */ h = (struct rtas_error_log *)&savep[1]; + extended_log_length = rtas_error_extended(h) ? rtas_error_extended_log_length(h) : 0; + len = struct_size(h, buffer, extended_log_length); + len = min(len, RTAS_ERROR_LOG_MAX); /* Use the per cpu buffer from paca to store rtas error log */ memset(local_paca->mce_data_buf, 0, RTAS_ERROR_LOG_MAX); - if (!rtas_error_extended(h)) { - memcpy(local_paca->mce_data_buf, h, sizeof(__u64)); - } else { - int len, error_log_length; - - error_log_length = 8 + rtas_error_extended_log_length(h); - len = min_t(int, error_log_length, RTAS_ERROR_LOG_MAX); - memcpy(local_paca->mce_data_buf, h, len); - } + memcpy(local_paca->mce_data_buf, h, len); return (struct rtas_error_log *)local_paca->mce_data_buf; } |
