* [PATCH] MIPS: generic/yamon-dt: fix uninitialized variable error
@ 2021-11-10 23:25 Colin Ian King
2021-11-10 23:26 ` Colin King (gmail)
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2021-11-10 23:25 UTC (permalink / raw)
To: Paul Burton, Thomas Bogendoerfer, Ralf Baechle, James Hogan, linux-mips
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In the case where fw_getenv returns an error when fetching values
for ememsizea and memsize then variable phys_memsize is not assigned
a variable and will be uninitialized on a zero check of phys_memsize.
Fix this by initializing phys_memsize to zero.
Cleans up cppcheck error:
arch/mips/generic/yamon-dt.c:100:7: error: Uninitialized variable: phys_memsize [uninitvar]
Fixes: f41d2430bbd6 ("MIPS: generic/yamon-dt: Support > 256MB of RAM")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
arch/mips/generic/yamon-dt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/generic/yamon-dt.c b/arch/mips/generic/yamon-dt.c
index a3aa22c77cad..a07a5edbcda7 100644
--- a/arch/mips/generic/yamon-dt.c
+++ b/arch/mips/generic/yamon-dt.c
@@ -75,7 +75,7 @@ static unsigned int __init gen_fdt_mem_array(
__init int yamon_dt_append_memory(void *fdt,
const struct yamon_mem_region *regions)
{
- unsigned long phys_memsize, memsize;
+ unsigned long phys_memsize = 0, memsize;
__be32 mem_array[2 * MAX_MEM_ARRAY_ENTRIES];
unsigned int mem_entries;
int i, err, mem_off;
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: generic/yamon-dt: fix uninitialized variable error
2021-11-10 23:25 [PATCH] MIPS: generic/yamon-dt: fix uninitialized variable error Colin Ian King
@ 2021-11-10 23:26 ` Colin King (gmail)
0 siblings, 0 replies; 2+ messages in thread
From: Colin King (gmail) @ 2021-11-10 23:26 UTC (permalink / raw)
To: Colin Ian King, Paul Burton, Thomas Bogendoerfer, Ralf Baechle,
James Hogan, linux-mips
Cc: kernel-janitors, linux-kernel
On 10/11/2021 23:25, Colin Ian King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the case where fw_getenv returns an error when fetching values
> for ememsizea and memsize then variable phys_memsize is not assigned
> a variable and will be uninitialized on a zero check of phys_memsize.
> Fix this by initializing phys_memsize to zero.
>
> Cleans up cppcheck error:
> arch/mips/generic/yamon-dt.c:100:7: error: Uninitialized variable: phys_memsize [uninitvar]
>
> Fixes: f41d2430bbd6 ("MIPS: generic/yamon-dt: Support > 256MB of RAM")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> arch/mips/generic/yamon-dt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/generic/yamon-dt.c b/arch/mips/generic/yamon-dt.c
> index a3aa22c77cad..a07a5edbcda7 100644
> --- a/arch/mips/generic/yamon-dt.c
> +++ b/arch/mips/generic/yamon-dt.c
> @@ -75,7 +75,7 @@ static unsigned int __init gen_fdt_mem_array(
> __init int yamon_dt_append_memory(void *fdt,
> const struct yamon_mem_region *regions)
> {
> - unsigned long phys_memsize, memsize;
> + unsigned long phys_memsize = 0, memsize;
> __be32 mem_array[2 * MAX_MEM_ARRAY_ENTRIES];
> unsigned int mem_entries;
> int i, err, mem_off;
>
Oops, old SoB. I'll resend a V2.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-10 23:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 23:25 [PATCH] MIPS: generic/yamon-dt: fix uninitialized variable error Colin Ian King
2021-11-10 23:26 ` Colin King (gmail)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.