Commit 92a486ca authored by Kees Cook's avatar Kees Cook Committed by David S. Miller

cxgb3: avoid needless buffer copy for firmware

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: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a55e1c5c
...@@ -1025,19 +1025,19 @@ int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size) ...@@ -1025,19 +1025,19 @@ int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size)
{ {
struct adapter *adapter = phy->adapter; struct adapter *adapter = phy->adapter;
const struct firmware *fw; const struct firmware *fw;
char buf[64]; const char *fw_name;
u32 csum; u32 csum;
const __be32 *p; const __be32 *p;
u16 *cache = phy->phy_cache; u16 *cache = phy->phy_cache;
int i, ret; int i, ret = -EINVAL;
snprintf(buf, sizeof(buf), get_edc_fw_name(edc_idx));
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) { if (ret < 0) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"could not upgrade firmware: unable to load %s\n", "could not upgrade firmware: unable to load %s\n",
buf); fw_name);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment