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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 iwpmd/iwarp_pm_common.c | 4 ++++
 1 file changed, 4 insertions(+)

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;
 	}
 }
 
-- 
2.29.2





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux