Skip to content

Commit

Permalink
cxgb3: avoid needless buffer copy for firmware
Browse files Browse the repository at this point in the history
There's no reason to perform a buffer copy for the firmware name. This
also avoids a (currently impossible with current callers) NULL dereference
if there was no matching firmware.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kees Cook authored and David S. Miller committed Jun 21, 2015
1 parent a55e1c5 commit 92a486c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,19 +1025,19 @@ int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size)
{
struct adapter *adapter = phy->adapter;
const struct firmware *fw;
char buf[64];
const char *fw_name;
u32 csum;
const __be32 *p;
u16 *cache = phy->phy_cache;
int i, ret;

snprintf(buf, sizeof(buf), get_edc_fw_name(edc_idx));
int i, ret = -EINVAL;

ret = request_firmware(&fw, buf, &adapter->pdev->dev);
fw_name = get_edc_fw_name(edc_idx);
if (fw_name)
ret = request_firmware(&fw, fw_name, &adapter->pdev->dev);
if (ret < 0) {
dev_err(&adapter->pdev->dev,
"could not upgrade firmware: unable to load %s\n",
buf);
fw_name);
return ret;
}

Expand Down

0 comments on commit 92a486c

Please sign in to comment.