From 7826d43f2db45c9305a6e0ba165650e1a203f517 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Sun, 6 Jan 2013 00:44:26 +0000 Subject: ethtool: fix drvinfo strings set in drivers Use strlcpy where possible to ensure the string is \0 terminated. Use always sizeof(string) instead of 32, ETHTOOL_BUSINFO_LEN and custom defines. Use snprintf instead of sprint. Remove unnecessary inits of ->fw_version Remove unnecessary inits of drvinfo struct. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/wimax/i2400m/netdev.c | 10 +++++----- drivers/net/wimax/i2400m/usb.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/net/wimax') diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c index 1d76ae855f07..cedd4d30d996 100644 --- a/drivers/net/wimax/i2400m/netdev.c +++ b/drivers/net/wimax/i2400m/netdev.c @@ -596,12 +596,12 @@ static void i2400m_get_drvinfo(struct net_device *net_dev, { struct i2400m *i2400m = net_dev_to_i2400m(net_dev); - strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1); - strncpy(info->fw_version, - i2400m->fw_name ? : "", sizeof(info->fw_version) - 1); + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->fw_version, i2400m->fw_name ? : "", + sizeof(info->fw_version)); if (net_dev->dev.parent) - strncpy(info->bus_info, dev_name(net_dev->dev.parent), - sizeof(info->bus_info) - 1); + strlcpy(info->bus_info, dev_name(net_dev->dev.parent), + sizeof(info->bus_info)); } static const struct ethtool_ops i2400m_ethtool_ops = { diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c index 080f36303a4f..cd15a93d9084 100644 --- a/drivers/net/wimax/i2400m/usb.c +++ b/drivers/net/wimax/i2400m/usb.c @@ -346,9 +346,9 @@ static void i2400mu_get_drvinfo(struct net_device *net_dev, struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m); struct usb_device *udev = i2400mu->usb_dev; - strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1); - strncpy(info->fw_version, - i2400m->fw_name ? : "", sizeof(info->fw_version) - 1); + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->fw_version, i2400m->fw_name ? : "", + sizeof(info->fw_version)); usb_make_path(udev, info->bus_info, sizeof(info->bus_info)); } -- cgit v1.2.3 From aaeb6cdfa5c07533c2cd6d2c381374c69f7db9dc Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Tue, 8 Jan 2013 01:38:26 +0000 Subject: remove init of dev->perm_addr in drivers perm_addr is initialized correctly in register_netdevice() so to init it in drivers is no longer needed. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/wimax/i2400m/fw.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/wimax') diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c index def12b38cbf7..c9c711dcd0e6 100644 --- a/drivers/net/wimax/i2400m/fw.c +++ b/drivers/net/wimax/i2400m/fw.c @@ -1055,7 +1055,6 @@ int i2400m_read_mac_addr(struct i2400m *i2400m) result = 0; } net_dev->addr_len = ETH_ALEN; - memcpy(net_dev->perm_addr, ack_buf.ack_pl, ETH_ALEN); memcpy(net_dev->dev_addr, ack_buf.ack_pl, ETH_ALEN); error_read_mac: d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, result); -- cgit v1.2.3 From 9d11bd1592fba0b9231d3ce8ab61977db7e03e27 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 3 Feb 2013 17:28:13 +0000 Subject: wimax: Remove unnecessary alloc/OOM messages, alloc cleanups alloc failures already get standardized OOM messages and a dump_stack. Convert kzalloc's with multiplies to kcalloc. Remove now unused size variables. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/wimax/i2400m/rx.c | 16 +++++----------- drivers/net/wimax/i2400m/usb-notif.c | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'drivers/net/wimax') diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 37becfcc98f2..8077e6e35939 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c @@ -1351,24 +1351,18 @@ int i2400m_rx_setup(struct i2400m *i2400m) i2400m->rx_reorder = i2400m_rx_reorder_disabled? 0 : 1; if (i2400m->rx_reorder) { unsigned itr; - size_t size; struct i2400m_roq_log *rd; result = -ENOMEM; - size = sizeof(i2400m->rx_roq[0]) * (I2400M_RO_CIN + 1); - i2400m->rx_roq = kzalloc(size, GFP_KERNEL); - if (i2400m->rx_roq == NULL) { - dev_err(dev, "RX: cannot allocate %zu bytes for " - "reorder queues\n", size); + i2400m->rx_roq = kcalloc(I2400M_RO_CIN + 1, + sizeof(i2400m->rx_roq[0]), GFP_KERNEL); + if (i2400m->rx_roq == NULL) goto error_roq_alloc; - } - size = sizeof(*i2400m->rx_roq[0].log) * (I2400M_RO_CIN + 1); - rd = kzalloc(size, GFP_KERNEL); + rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log), + GFP_KERNEL); if (rd == NULL) { - dev_err(dev, "RX: cannot allocate %zu bytes for " - "reorder queues log areas\n", size); result = -ENOMEM; goto error_roq_log_alloc; } diff --git a/drivers/net/wimax/i2400m/usb-notif.c b/drivers/net/wimax/i2400m/usb-notif.c index d44b545f4082..fc1355d98bc6 100644 --- a/drivers/net/wimax/i2400m/usb-notif.c +++ b/drivers/net/wimax/i2400m/usb-notif.c @@ -199,7 +199,6 @@ int i2400mu_notification_setup(struct i2400mu *i2400mu) d_fnstart(4, dev, "(i2400m %p)\n", i2400mu); buf = kmalloc(I2400MU_MAX_NOTIFICATION_LEN, GFP_KERNEL | GFP_DMA); if (buf == NULL) { - dev_err(dev, "notification: buffer allocation failed\n"); ret = -ENOMEM; goto error_buf_alloc; } -- cgit v1.2.3 From efc496eb317ce46755acc46172daa0992b184ed0 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 4 Feb 2013 18:22:29 +0000 Subject: drivers: net: misc: Remove unused OOM variables commits 9d11bd159 ("wimax: Remove unnecessary alloc/OOM messages, alloc cleanups") and b2adaca92 ("ethernet: Remove unnecessary alloc/OOM messages, alloc cleanups") added a couple of unused variable warnings. Remove the now unused variables. Noticed-by: kbuild test robot Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/wimax/i2400m/rx.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/wimax') diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 8077e6e35939..0b602951ff6b 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c @@ -1346,7 +1346,6 @@ EXPORT_SYMBOL(i2400m_unknown_barker); int i2400m_rx_setup(struct i2400m *i2400m) { int result = 0; - struct device *dev = i2400m_dev(i2400m); i2400m->rx_reorder = i2400m_rx_reorder_disabled? 0 : 1; if (i2400m->rx_reorder) { -- cgit v1.2.3