Skip to content

Commit f7e8cdc

Browse files
Christian Engelmayergregkh
Christian Engelmayer
authored andcommitted
rsi: Fix possible leak when loading firmware
commit a8b9774 upstream. Commit 5d5cd85 ("rsi: Fix failure to load firmware after memory leak fix and fix the leak") also added a check on the allocation of DMA-accessible memory that may directly return. In that case the already allocated firmware data is leaked. Make sure the data is always freed correctly. Detected by Coverity CID 1316519. Fixes: 5d5cd85 ("rsi: Fix failure to load firmware after memory leak fix and fix the leak") Signed-off-by: Christian Engelmayer <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f4cbe79 commit f7e8cdc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

drivers/net/wireless/rsi/rsi_91x_sdio_ops.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common)
203203

204204
/* Copy firmware into DMA-accessible memory */
205205
fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
206-
if (!fw)
207-
return -ENOMEM;
206+
if (!fw) {
207+
status = -ENOMEM;
208+
goto out;
209+
}
208210
len = fw_entry->size;
209211

210212
if (len % 4)
@@ -217,6 +219,8 @@ static int rsi_load_ta_instructions(struct rsi_common *common)
217219

218220
status = rsi_copy_to_card(common, fw, len, num_blocks);
219221
kfree(fw);
222+
223+
out:
220224
release_firmware(fw_entry);
221225
return status;
222226
}

drivers/net/wireless/rsi/rsi_91x_usb_ops.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common)
148148

149149
/* Copy firmware into DMA-accessible memory */
150150
fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
151-
if (!fw)
152-
return -ENOMEM;
151+
if (!fw) {
152+
status = -ENOMEM;
153+
goto out;
154+
}
153155
len = fw_entry->size;
154156

155157
if (len % 4)
@@ -162,6 +164,8 @@ static int rsi_load_ta_instructions(struct rsi_common *common)
162164

163165
status = rsi_copy_to_card(common, fw, len, num_blocks);
164166
kfree(fw);
167+
168+
out:
165169
release_firmware(fw_entry);
166170
return status;
167171
}

0 commit comments

Comments
 (0)