summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2019-05-29 21:13:58 +0200
committerDavid S. Miller <davem@davemloft.net>2019-05-30 14:39:25 -0700
commite95a7f30e1261f03487b15a8bd55bb812ceaa18b (patch)
treeecf43c79c73b3d6f1683237874c344678f37b310 /drivers
parent25e94115aee6dc8fb088a57945974d334eb72575 (diff)
downloadlinux-e95a7f30e1261f03487b15a8bd55bb812ceaa18b.tar.bz2
r8169: improve rtl_fw_format_ok
Simplify the function a little bit and use strscpy() where appropriate. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/realtek/r8169.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 1f98e450b8cb..708df783c51f 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -2314,50 +2314,45 @@ static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
const struct firmware *fw = rtl_fw->fw;
struct fw_info *fw_info = (struct fw_info *)fw->data;
struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
- char *version = rtl_fw->version;
- bool rc = false;
if (fw->size < FW_OPCODE_SIZE)
- goto out;
+ return false;
if (!fw_info->magic) {
size_t i, size, start;
u8 checksum = 0;
if (fw->size < sizeof(*fw_info))
- goto out;
+ return false;
for (i = 0; i < fw->size; i++)
checksum += fw->data[i];
if (checksum != 0)
- goto out;
+ return false;
start = le32_to_cpu(fw_info->fw_start);
if (start > fw->size)
- goto out;
+ return false;
size = le32_to_cpu(fw_info->fw_len);
if (size > (fw->size - start) / FW_OPCODE_SIZE)
- goto out;
+ return false;
- memcpy(version, fw_info->version, RTL_VER_SIZE);
+ strscpy(rtl_fw->version, fw_info->version, RTL_VER_SIZE);
pa->code = (__le32 *)(fw->data + start);
pa->size = size;
} else {
if (fw->size % FW_OPCODE_SIZE)
- goto out;
+ return false;
- strlcpy(version, tp->fw_name, RTL_VER_SIZE);
+ strscpy(rtl_fw->version, tp->fw_name, RTL_VER_SIZE);
pa->code = (__le32 *)fw->data;
pa->size = fw->size / FW_OPCODE_SIZE;
}
- version[RTL_VER_SIZE - 1] = 0;
- rc = true;
-out:
- return rc;
+ return true;
}
static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,