* [PATCH] cxgb3: avoid needless buffer copy for firmware
@ 2015-06-16 22:36 Kees Cook
2015-06-21 16:50 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2015-06-16 22:36 UTC (permalink / raw)
To: linux-kernel; +Cc: Santosh Raspatur, netdev, Alexander Gordeev, Joe Perches
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>
---
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index b96e4bfcac41..8f7aa53a4c4b 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -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;
}
--
1.9.1
--
Kees Cook
Chrome OS Security
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cxgb3: avoid needless buffer copy for firmware
2015-06-16 22:36 [PATCH] cxgb3: avoid needless buffer copy for firmware Kees Cook
@ 2015-06-21 16:50 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-06-21 16:50 UTC (permalink / raw)
To: keescook; +Cc: linux-kernel, santosh, netdev, agordeev, joe
From: Kees Cook <keescook@chromium.org>
Date: Tue, 16 Jun 2015 15:36:17 -0700
> 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>
Applied to net-next, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cxgb3: avoid needless buffer copy for firmware
@ 2015-06-21 16:50 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-06-21 16:50 UTC (permalink / raw)
To: keescook; +Cc: linux-kernel, santosh, netdev, agordeev, joe
From: Kees Cook <keescook@chromium.org>
Date: Tue, 16 Jun 2015 15:36:17 -0700
> 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>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-21 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16 22:36 [PATCH] cxgb3: avoid needless buffer copy for firmware Kees Cook
2015-06-21 16:50 ` David Miller
2015-06-21 16:50 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.