OSDN Git Service

virtio-crypto: fix uninitialized variables
authorGonglei <arei.gonglei@huawei.com>
Sat, 26 Nov 2016 03:07:55 +0000 (11:07 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 30 Nov 2016 02:22:18 +0000 (04:22 +0200)
commit9730280d54634caa5d63f0d8fcd85da8311d2ebf
tree00ea06f4cf6e73fe8010b100d463e98143dbb434
parent1b57bd4f2f4993104a5cb48912435396faa10d58
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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/virtio-crypto.c