All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] virtio-crypto: fix uninitialized variables
@ 2016-11-26  3:07 Gonglei
  2016-12-01  3:38 ` Gonglei (Arei)
  0 siblings, 1 reply; 3+ messages in thread
From: Gonglei @ 2016-11-26  3:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, Gonglei

Though crypto_cfg.reserve is an unused field, let me
initialize the structure in order to make coverity happy.

*** CID 1365923:  Uninitialized variables  (UNINIT)
/hw/virtio/virtio-crypto.c: 851 in virtio_crypto_get_config()
845         stl_le_p(&crypto_cfg.mac_algo_h, c->conf.mac_algo_h);
846         stl_le_p(&crypto_cfg.aead_algo, c->conf.aead_algo);
847         stl_le_p(&crypto_cfg.max_cipher_key_len, c->conf.max_cipher_key_len);
848         stl_le_p(&crypto_cfg.max_auth_key_len, c->conf.max_auth_key_len);
849         stq_le_p(&crypto_cfg.max_size, c->conf.max_size);
850
>>>     CID 1365923:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "crypto_cfg". Field "crypto_cfg.reserve"
       is uninitialized when calling "memcpy".
      [Note: The source code implementation of the function
       has been overridden by a builtin model.]
851         memcpy(config, &crypto_cfg, c->config_size);
852     }
853

Rported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 v2: initialize the whole structure instead of the 
     single crypto_cfg.reserve for better extension.
---
 hw/virtio/virtio-crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 847dc9d..2f2467e 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -838,7 +838,7 @@ static Property virtio_crypto_properties[] = {
 static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
 {
     VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
-    struct virtio_crypto_config crypto_cfg;
+    struct virtio_crypto_config crypto_cfg = {};
 
     /*
      * Virtio-crypto device conforms to VIRTIO 1.0 which is always LE,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-crypto: fix uninitialized variables
  2016-11-26  3:07 [Qemu-devel] [PATCH v2] virtio-crypto: fix uninitialized variables Gonglei
@ 2016-12-01  3:38 ` Gonglei (Arei)
  2016-12-01  3:52   ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Gonglei (Arei) @ 2016-12-01  3:38 UTC (permalink / raw)
  To: Gonglei (Arei), qemu-devel@nongnu.org; +Cc: mst@redhat.com

Hi Michael,

Pls pick up this one for 2.8. 

Thanks,
-Gonglei


> -----Original Message-----
> From: Gonglei (Arei)
> Sent: Saturday, November 26, 2016 11:08 AM
> To: qemu-devel@nongnu.org
> Cc: mst@redhat.com; Gonglei (Arei)
> Subject: [PATCH v2] virtio-crypto: fix uninitialized variables
> 
> Though crypto_cfg.reserve is an unused field, let me
> initialize the structure in order to make coverity happy.
> 
> *** CID 1365923:  Uninitialized variables  (UNINIT)
> /hw/virtio/virtio-crypto.c: 851 in virtio_crypto_get_config()
> 845         stl_le_p(&crypto_cfg.mac_algo_h, c->conf.mac_algo_h);
> 846         stl_le_p(&crypto_cfg.aead_algo, c->conf.aead_algo);
> 847         stl_le_p(&crypto_cfg.max_cipher_key_len,
> c->conf.max_cipher_key_len);
> 848         stl_le_p(&crypto_cfg.max_auth_key_len,
> c->conf.max_auth_key_len);
> 849         stq_le_p(&crypto_cfg.max_size, c->conf.max_size);
> 850
> >>>     CID 1365923:  Uninitialized variables  (UNINIT)
> >>>     Using uninitialized value "crypto_cfg". Field "crypto_cfg.reserve"
>        is uninitialized when calling "memcpy".
>       [Note: The source code implementation of the function
>        has been overridden by a builtin model.]
> 851         memcpy(config, &crypto_cfg, c->config_size);
> 852     }
> 853
> 
> Rported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  v2: initialize the whole structure instead of the
>      single crypto_cfg.reserve for better extension.
> ---
>  hw/virtio/virtio-crypto.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
> index 847dc9d..2f2467e 100644
> --- a/hw/virtio/virtio-crypto.c
> +++ b/hw/virtio/virtio-crypto.c
> @@ -838,7 +838,7 @@ static Property virtio_crypto_properties[] = {
>  static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
>  {
>      VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
> -    struct virtio_crypto_config crypto_cfg;
> +    struct virtio_crypto_config crypto_cfg = {};
> 
>      /*
>       * Virtio-crypto device conforms to VIRTIO 1.0 which is always LE,
> --
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-crypto: fix uninitialized variables
  2016-12-01  3:38 ` Gonglei (Arei)
@ 2016-12-01  3:52   ` Michael S. Tsirkin
  0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2016-12-01  3:52 UTC (permalink / raw)
  To: Gonglei (Arei); +Cc: qemu-devel@nongnu.org

On Thu, Dec 01, 2016 at 03:38:50AM +0000, Gonglei (Arei) wrote:
> Hi Michael,
> 
> Pls pick up this one for 2.8. 
> 
> Thanks,
> -Gonglei
> 
> 
> > -----Original Message-----
> > From: Gonglei (Arei)
> > Sent: Saturday, November 26, 2016 11:08 AM
> > To: qemu-devel@nongnu.org
> > Cc: mst@redhat.com; Gonglei (Arei)
> > Subject: [PATCH v2] virtio-crypto: fix uninitialized variables
> > 
> > Though crypto_cfg.reserve is an unused field, let me
> > initialize the structure in order to make coverity happy.
> > 
> > *** CID 1365923:  Uninitialized variables  (UNINIT)
> > /hw/virtio/virtio-crypto.c: 851 in virtio_crypto_get_config()
> > 845         stl_le_p(&crypto_cfg.mac_algo_h, c->conf.mac_algo_h);
> > 846         stl_le_p(&crypto_cfg.aead_algo, c->conf.aead_algo);
> > 847         stl_le_p(&crypto_cfg.max_cipher_key_len,
> > c->conf.max_cipher_key_len);
> > 848         stl_le_p(&crypto_cfg.max_auth_key_len,
> > c->conf.max_auth_key_len);
> > 849         stq_le_p(&crypto_cfg.max_size, c->conf.max_size);
> > 850
> > >>>     CID 1365923:  Uninitialized variables  (UNINIT)
> > >>>     Using uninitialized value "crypto_cfg". Field "crypto_cfg.reserve"
> >        is uninitialized when calling "memcpy".
> >       [Note: The source code implementation of the function
> >        has been overridden by a builtin model.]
> > 851         memcpy(config, &crypto_cfg, c->config_size);
> > 852     }
> > 853
> > 
> > Rported-by: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> >  v2: initialize the whole structure instead of the
> >      single crypto_cfg.reserve for better extension.
> > ---
> >  hw/virtio/virtio-crypto.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
> > index 847dc9d..2f2467e 100644
> > --- a/hw/virtio/virtio-crypto.c
> > +++ b/hw/virtio/virtio-crypto.c
> > @@ -838,7 +838,7 @@ static Property virtio_crypto_properties[] = {
> >  static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
> >  {
> >      VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
> > -    struct virtio_crypto_config crypto_cfg;
> > +    struct virtio_crypto_config crypto_cfg = {};
> > 
> >      /*
> >       * Virtio-crypto device conforms to VIRTIO 1.0 which is always LE,
> > --
> > 1.8.3.1
> > 


Yes, I got this one too.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-01  3:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-26  3:07 [Qemu-devel] [PATCH v2] virtio-crypto: fix uninitialized variables Gonglei
2016-12-01  3:38 ` Gonglei (Arei)
2016-12-01  3:52   ` Michael S. Tsirkin

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.