Skip to content

Commit

Permalink
rsi: Fix possible leak when loading firmware
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Christian Engelmayer authored and gregkh committed Oct 22, 2015
1 parent f4cbe79 commit f7e8cdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common)

/* Copy firmware into DMA-accessible memory */
fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
if (!fw)
return -ENOMEM;
if (!fw) {
status = -ENOMEM;
goto out;
}
len = fw_entry->size;

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

status = rsi_copy_to_card(common, fw, len, num_blocks);
kfree(fw);

out:
release_firmware(fw_entry);
return status;
}
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/wireless/rsi/rsi_91x_usb_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common)

/* Copy firmware into DMA-accessible memory */
fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
if (!fw)
return -ENOMEM;
if (!fw) {
status = -ENOMEM;
goto out;
}
len = fw_entry->size;

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

status = rsi_copy_to_card(common, fw, len, num_blocks);
kfree(fw);

out:
release_firmware(fw_entry);
return status;
}
Expand Down

0 comments on commit f7e8cdc

Please sign in to comment.