Skip to contentSkip to conversation

iwlwifi/fw: use struct_size over open coded arithmetic

PATCH New [email protected] 1 participant 1 message Feb 16, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwlwifi/fw: use struct_size over open coded arithmetic

From: "Minghao Chi (CGEL ZTE)" <[email protected]>

Replace zero-length array with flexible-array member and make use of the struct_size() helper in kzalloc().

---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +1 -1
index 7ad9cee925da..b147d38033d8 100644
@@ -2589,7 +2589,7 @@ int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,
 		delay = le32_to_cpu(trigger->stop_delay) * USEC_PER_MSEC;
 	}
 
-	desc = kzalloc(sizeof(*desc) + len, GFP_ATOMIC);
+	desc = kzalloc(struct_size(desc, trig_desc.data, len), GFP_ATOMIC);
 	if (!desc)
 		return -ENOMEM;
 
Signature · 1 line
2.25.1