Skip to content

Commit 223e228

Browse files
harsha-broadcomPaolo Abeni
authored andcommitted
vsock/vmci: Clear the vmci transport packet properly when initializing it
In vmci_transport_packet_init memset the vmci_transport_packet before populating the fields to avoid any uninitialised data being left in the structure. Cc: Bryan Tan <bryan-bt.tan@broadcom.com> Cc: Vishnu Dasa <vishnu.dasa@broadcom.com> Cc: Broadcom internal kernel review list Cc: Stefano Garzarella <sgarzare@redhat.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Simon Horman <horms@kernel.org> Cc: virtualization@lists.linux.dev Cc: netdev@vger.kernel.org Cc: stable <stable@kernel.org> Signed-off-by: HarshaVardhana S A <harshavardhana.sa@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Fixes: d021c34 ("VSOCK: Introduce VM Sockets") Acked-by: Stefano Garzarella <sgarzare@redhat.com> Link: https://patch.msgid.link/20250701122254.2397440-1-gregkh@linuxfoundation.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent f030713 commit 223e228

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/vmw_vsock/vmci_transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,
119119
u16 proto,
120120
struct vmci_handle handle)
121121
{
122+
memset(pkt, 0, sizeof(*pkt));
123+
122124
/* We register the stream control handler as an any cid handle so we
123125
* must always send from a source address of VMADDR_CID_ANY
124126
*/
@@ -131,8 +133,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,
131133
pkt->type = type;
132134
pkt->src_port = src->svm_port;
133135
pkt->dst_port = dst->svm_port;
134-
memset(&pkt->proto, 0, sizeof(pkt->proto));
135-
memset(&pkt->_reserved2, 0, sizeof(pkt->_reserved2));
136136

137137
switch (pkt->type) {
138138
case VMCI_TRANSPORT_PACKET_TYPE_INVALID:

0 commit comments

Comments
 (0)