diff mbox

[1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string

Message ID 1332761036-8913-1-git-send-email-phil.sutter@viprinet.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Phil Sutter March 26, 2012, 11:23 a.m. UTC
This happened on a machine with a custom hotplug script calling nameif,
probably due to slow firmware loading. At the time nameif uses ethtool
to gather interface information, i2400m->fw_name is zero and so a null
pointer dereference occurs from within i2400m_get_drvinfo().

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
---
 drivers/net/wimax/i2400m/netdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Ben Hutchings March 26, 2012, 2:57 p.m. UTC | #1
On Mon, 2012-03-26 at 13:23 +0200, Phil Sutter wrote:
> This happened on a machine with a custom hotplug script calling nameif,
> probably due to slow firmware loading. At the time nameif uses ethtool
> to gather interface information, i2400m->fw_name is zero and so a null
> pointer dereference occurs from within i2400m_get_drvinfo().
> 
> Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
> ---
>  drivers/net/wimax/i2400m/netdev.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
> index 64a1106..020bd8d 100644
> --- a/drivers/net/wimax/i2400m/netdev.c
> +++ b/drivers/net/wimax/i2400m/netdev.c
> @@ -607,7 +607,8 @@ 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);
> +	strncpy(info->fw_version,
> +	        i2400m->fw_name ? : "N/A", sizeof(info->fw_version) - 1);

Use an empty string, not "N/A".

Ben.

>  	if (net_dev->dev.parent)
>  		strncpy(info->bus_info, dev_name(net_dev->dev.parent),
>  			sizeof(info->bus_info) - 1);
David Miller March 28, 2012, 2:30 a.m. UTC | #2
From: Phil Sutter <phil.sutter@viprinet.com>
Date: Mon, 26 Mar 2012 13:23:55 +0200

> This happened on a machine with a custom hotplug script calling nameif,
> probably due to slow firmware loading. At the time nameif uses ethtool
> to gather interface information, i2400m->fw_name is zero and so a null
> pointer dereference occurs from within i2400m_get_drvinfo().
> 
> Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 64a1106..020bd8d 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -607,7 +607,8 @@  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);
+	strncpy(info->fw_version,
+	        i2400m->fw_name ? : "N/A", sizeof(info->fw_version) - 1);
 	if (net_dev->dev.parent)
 		strncpy(info->bus_info, dev_name(net_dev->dev.parent),
 			sizeof(info->bus_info) - 1);