diff mbox series

[3/4] iwpmd: Always copy the ss_family in copy_iwpm_sockaddr()

Message ID 3-v1-f03f70229014+144-fix_lto_jgg@nvidia.com (mailing list archive)
State Not Applicable
Headers show
Series Enable LTO support for rdma-core | expand

Commit Message

Jason Gunthorpe Nov. 16, 2020, 8:16 p.m. UTC
gcc10 with LTO finds a path where process_iwpm_wire_request() calls
copy_iwpm_sockaddr() and then does print_iwpm_sockaddr() against the
dst. If the case statement in copy_iwpm_sockaddr() bails then
print_iwpm_sockaddr() is still called and this triggers a read from
uninitialized memory.

Always copy the ss_family, this will cause the default case to be taken in
print_iwpm_sockaddr() as well.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 iwpmd/iwarp_pm_common.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/iwpmd/iwarp_pm_common.c b/iwpmd/iwarp_pm_common.c
index 8160180aee48e8..67309cbee6a057 100644
--- a/iwpmd/iwarp_pm_common.c
+++ b/iwpmd/iwarp_pm_common.c
@@ -570,6 +570,10 @@  void copy_iwpm_sockaddr(__u16 addr_family, struct sockaddr_storage *src_sockaddr
 		*dst = *src;
 		break;
 	}
+	default:
+	assert(false);
+	if (dst_sockaddr)
+		dst_sockaddr->ss_family = addr_family;
 	}
 }