[PATCH] wifi: iwlwifi: mei: fix const qualifier of the NVM allocation

From: Andrei Rusu de Castro

Date: Sun Nov 15 2026 - 19:56:28 EST


Commit 69050f8d6d07 ("treewide: Replace kmalloc with kmalloc_obj for
non-scalar types") turned the allocation of mei->nvm in
iwl_mei_handle_nvm() into kzalloc_obj(*mei_nvm). mei_nvm points to the
received SAP message and is const-qualified, so the allocation is typed
const struct iwl_mei_nvm * and assigning it to mei->nvm discards the
qualifier:

drivers/net/wireless/intel/iwlwifi/mei/main.c:890:18: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

This is a warning by default and breaks the build with CONFIG_WERROR. It
went unnoticed because IWLMEI depends on BROKEN.

Size the allocation by the destination instead and drop mei_nvm, which
has no other use.

Fixes: 69050f8d6d07 ("treewide: Replace kmalloc with kmalloc_obj for non-scalar types")
Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works>
---
drivers/net/wireless/intel/iwlwifi/mei/main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index ce92e26c42d7..d260bc5b96c3 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -883,11 +883,10 @@ static void iwl_mei_handle_nvm(struct mei_cl_device *cldev,
const struct iwl_sap_nvm *sap_nvm)
{
struct iwl_mei *mei = mei_cldev_get_drvdata(cldev);
- const struct iwl_mei_nvm *mei_nvm = (const void *)sap_nvm;
int i;

kfree(mei->nvm);
- mei->nvm = kzalloc_obj(*mei_nvm);
+ mei->nvm = kzalloc_obj(*mei->nvm);
if (!mei->nvm)
return;

--
2.55.0