[PATCH 5/6] net/passt: Initialize "error" variable in net_passt_send() (CID 1612368)

Laurent Vivier posted 6 patches 4 months ago
Maintainers: Jason Wang <jasowang@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
[PATCH 5/6] net/passt: Initialize "error" variable in net_passt_send() (CID 1612368)
Posted by Laurent Vivier 4 months ago
This was flagged by Coverity as a memory illegal access.

Initialize the pointer to NULL at declaration.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 net/passt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/passt.c b/net/passt.c
index 43c336e5968c..32ecffb763b4 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -124,7 +124,7 @@ static gboolean net_passt_send(QIOChannel *ioc, GIOCondition condition,
 {
     if (net_stream_data_send(ioc, condition, data) == G_SOURCE_REMOVE) {
         NetPasstState *s = DO_UPCAST(NetPasstState, data, data);
-        Error *error;
+        Error *error = NULL;
 
         /* we need to restart passt */
         kill(s->pid, SIGTERM);
-- 
2.49.0
Re: [PATCH 5/6] net/passt: Initialize "error" variable in net_passt_send() (CID 1612368)
Posted by Peter Maydell 3 months, 4 weeks ago
On Thu, 17 Jul 2025 at 18:51, Laurent Vivier <lvivier@redhat.com> wrote:
>
> This was flagged by Coverity as a memory illegal access.
>
> Initialize the pointer to NULL at declaration.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  net/passt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/passt.c b/net/passt.c
> index 43c336e5968c..32ecffb763b4 100644
> --- a/net/passt.c
> +++ b/net/passt.c
> @@ -124,7 +124,7 @@ static gboolean net_passt_send(QIOChannel *ioc, GIOCondition condition,
>  {
>      if (net_stream_data_send(ioc, condition, data) == G_SOURCE_REMOVE) {
>          NetPasstState *s = DO_UPCAST(NetPasstState, data, data);
> -        Error *error;
> +        Error *error = NULL;
>
>          /* we need to restart passt */
>          kill(s->pid, SIGTERM);
> --
> 2.49.0
>
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM