* [PATCH] aspeed/hace: Initialize g_autofree pointer
@ 2023-04-21 13:15 Cédric Le Goater
2023-04-21 13:25 ` Cédric Le Goater
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Cédric Le Goater @ 2023-04-21 13:15 UTC (permalink / raw)
To: qemu-arm
Cc: qemu-devel, Peter Maydell, Thomas Huth, Andrew Jeffery,
Cédric Le Goater, Steven Lee, Joel Stanley
As mentioned in docs/devel/style.rst "Automatic memory deallocation":
* Variables declared with g_auto* MUST always be initialized,
otherwise the cleanup function will use uninitialized stack memory
This avoids QEMU to coredump when running the "hash test" command
under Zephyr.
Cc: Steven Lee <steven_lee@aspeedtech.com>
Cc: Joel Stanley <joel@jms.id.au>
Fixes: c5475b3f9a ("hw: Model ASPEED's Hash and Crypto Engine")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/misc/aspeed_hace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
index 12a761f1f5..b07506ec04 100644
--- a/hw/misc/aspeed_hace.c
+++ b/hw/misc/aspeed_hace.c
@@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
bool acc_mode)
{
struct iovec iov[ASPEED_HACE_MAX_SG];
- g_autofree uint8_t *digest_buf;
+ g_autofree uint8_t *digest_buf = NULL;
size_t digest_len = 0;
int niov = 0;
int i;
--
2.40.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed/hace: Initialize g_autofree pointer
2023-04-21 13:15 [PATCH] aspeed/hace: Initialize g_autofree pointer Cédric Le Goater
@ 2023-04-21 13:25 ` Cédric Le Goater
2023-04-21 13:28 ` Alex Bennée
2023-04-25 9:21 ` Thomas Huth
2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2023-04-21 13:25 UTC (permalink / raw)
To: qemu-arm
Cc: qemu-devel, Peter Maydell, Thomas Huth, Andrew Jeffery,
Steven Lee, Joel Stanley, Alex Bennée
On 4/21/23 15:15, Cédric Le Goater wrote:
> As mentioned in docs/devel/style.rst "Automatic memory deallocation":
>
> * Variables declared with g_auto* MUST always be initialized,
> otherwise the cleanup function will use uninitialized stack memory
>
> This avoids QEMU to coredump when running the "hash test" command
> under Zephyr.
>
> Cc: Steven Lee <steven_lee@aspeedtech.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Fixes: c5475b3f9a ("hw: Model ASPEED's Hash and Crypto Engine")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Alex,
FYI, with Thomas's fixes and this oneliner, make check-avocado ran fine
with avocado bumped to version 100.1.
Cheers,
C.
> ---
> hw/misc/aspeed_hace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
> index 12a761f1f5..b07506ec04 100644
> --- a/hw/misc/aspeed_hace.c
> +++ b/hw/misc/aspeed_hace.c
> @@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
> bool acc_mode)
> {
> struct iovec iov[ASPEED_HACE_MAX_SG];
> - g_autofree uint8_t *digest_buf;
> + g_autofree uint8_t *digest_buf = NULL;
> size_t digest_len = 0;
> int niov = 0;
> int i;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed/hace: Initialize g_autofree pointer
2023-04-21 13:15 [PATCH] aspeed/hace: Initialize g_autofree pointer Cédric Le Goater
2023-04-21 13:25 ` Cédric Le Goater
@ 2023-04-21 13:28 ` Alex Bennée
2023-04-25 9:21 ` Thomas Huth
2 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2023-04-21 13:28 UTC (permalink / raw)
To: Cédric Le Goater
Cc: qemu-devel, Peter Maydell, Thomas Huth, Andrew Jeffery,
Steven Lee, Joel Stanley, qemu-arm
Cédric Le Goater <clg@kaod.org> writes:
> As mentioned in docs/devel/style.rst "Automatic memory deallocation":
>
> * Variables declared with g_auto* MUST always be initialized,
> otherwise the cleanup function will use uninitialized stack memory
>
> This avoids QEMU to coredump when running the "hash test" command
> under Zephyr.
>
> Cc: Steven Lee <steven_lee@aspeedtech.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Fixes: c5475b3f9a ("hw: Model ASPEED's Hash and Crypto Engine")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed/hace: Initialize g_autofree pointer
2023-04-21 13:15 [PATCH] aspeed/hace: Initialize g_autofree pointer Cédric Le Goater
2023-04-21 13:25 ` Cédric Le Goater
2023-04-21 13:28 ` Alex Bennée
@ 2023-04-25 9:21 ` Thomas Huth
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2023-04-25 9:21 UTC (permalink / raw)
To: Cédric Le Goater, qemu-arm
Cc: qemu-devel, Peter Maydell, Andrew Jeffery, Steven Lee,
Joel Stanley, QEMU Trivial
On 21/04/2023 15.15, Cédric Le Goater wrote:
> As mentioned in docs/devel/style.rst "Automatic memory deallocation":
>
> * Variables declared with g_auto* MUST always be initialized,
> otherwise the cleanup function will use uninitialized stack memory
>
> This avoids QEMU to coredump when running the "hash test" command
> under Zephyr.
>
> Cc: Steven Lee <steven_lee@aspeedtech.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Fixes: c5475b3f9a ("hw: Model ASPEED's Hash and Crypto Engine")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/misc/aspeed_hace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
> index 12a761f1f5..b07506ec04 100644
> --- a/hw/misc/aspeed_hace.c
> +++ b/hw/misc/aspeed_hace.c
> @@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
> bool acc_mode)
> {
> struct iovec iov[ASPEED_HACE_MAX_SG];
> - g_autofree uint8_t *digest_buf;
> + g_autofree uint8_t *digest_buf = NULL;
We maybe need a checkpatch.pl rule to catch such bugs...
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-25 9:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-21 13:15 [PATCH] aspeed/hace: Initialize g_autofree pointer Cédric Le Goater
2023-04-21 13:25 ` Cédric Le Goater
2023-04-21 13:28 ` Alex Bennée
2023-04-25 9:21 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).