[SWDEV-558046] Fix topology weight corruption due to casting

The out of bound writes caused corruption in next field,
which was weight. Fixed by reading to a temp and then assigning
safely.

Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
This commit is contained in:
Bindhiya Kanangot Balakrishnan
2025-10-29 18:19:32 -05:00
committed by Arif, Maisam
parent 0a5fdc944f
commit a2aae5e8a9
+3 -1
View File
@@ -351,6 +351,7 @@ int IOLink::ReadProperties(void) {
int
IOLink::Initialize(void) {
int ret = 0;
uint64_t tmp64 = 0;
ret = ReadProperties();
if (ret) {return ret;}
@@ -369,8 +370,9 @@ IOLink::Initialize(void) {
ret = get_property_value(kIOLinkPropWEIGHTStr, &weight_);
if (ret) {return ret;}
ret = get_property_value(kIOLinkPropFLAGSStr, reinterpret_cast<uint64_t *>(&flags_));
ret = get_property_value(kIOLinkPropFLAGSStr, &tmp64);
if (ret) {return ret;}
flags_ = static_cast<uint32_t>(tmp64);
ret = UpdateP2pCapability();
if (ret) {return ret;}