All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string
@ 2012-03-26 11:23 Phil Sutter
  2012-03-26 11:23 ` [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Phil Sutter @ 2012-03-26 11:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, inaky.perez-gonzalez

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);
 	if (net_dev->dev.parent)
 		strncpy(info->bus_info, dev_name(net_dev->dev.parent),
 			sizeof(info->bus_info) - 1);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops
  2012-03-26 11:23 [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Phil Sutter
@ 2012-03-26 11:23 ` Phil Sutter
  2012-03-28  2:30   ` David Miller
  2012-03-26 14:57 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Ben Hutchings
  2012-03-28  2:30 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string David Miller
  2 siblings, 1 reply; 7+ messages in thread
From: Phil Sutter @ 2012-03-26 11:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, inaky.perez-gonzalez

This way the USB variant of the driver uses usb_make_path in order to
provide bus-info compatible to other USB drivers (like e.g. asix.c).

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

diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 2c1b8b6..096a228 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -339,6 +339,23 @@ int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
 	return result;
 }
 
+static void i2400mu_get_drvinfo(struct net_device *net_dev,
+                                struct ethtool_drvinfo *info)
+{
+	struct i2400m *i2400m = net_dev_to_i2400m(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 ? : "N/A", sizeof(info->fw_version) - 1);
+	usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
+}
+
+static const struct ethtool_ops i2400mu_ethtool_ops = {
+	.get_drvinfo = i2400mu_get_drvinfo,
+	.get_link = ethtool_op_get_link,
+};
 
 static
 void i2400mu_netdev_setup(struct net_device *net_dev)
@@ -347,6 +364,7 @@ void i2400mu_netdev_setup(struct net_device *net_dev)
 	struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
 	i2400mu_init(i2400mu);
 	i2400m_netdev_setup(net_dev);
+	net_dev->ethtool_ops = &i2400mu_ethtool_ops;
 }
 
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string
  2012-03-26 11:23 [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Phil Sutter
  2012-03-26 11:23 ` [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
@ 2012-03-26 14:57 ` Ben Hutchings
  2012-03-26 19:01   ` [PATCHv2 " Phil Sutter
  2012-03-28  2:30 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string David Miller
  2 siblings, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2012-03-26 14:57 UTC (permalink / raw)
  To: Phil Sutter; +Cc: David Miller, netdev, inaky.perez-gonzalez

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);

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv2 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string
  2012-03-26 14:57 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Ben Hutchings
@ 2012-03-26 19:01   ` Phil Sutter
  2012-03-26 19:01     ` [PATCHv2 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Sutter @ 2012-03-26 19:01 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, inaky.perez-gonzalez, Ben Hutchings

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 63e4b70..1d76ae8 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -597,7 +597,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 ? : "", 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);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv2 2/2] wimax: i2400m-usb - use a private struct ethtool_ops
  2012-03-26 19:01   ` [PATCHv2 " Phil Sutter
@ 2012-03-26 19:01     ` Phil Sutter
  0 siblings, 0 replies; 7+ messages in thread
From: Phil Sutter @ 2012-03-26 19:01 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, inaky.perez-gonzalez, Ben Hutchings

This way the USB variant of the driver uses usb_make_path in order to
provide bus-info compatible to other USB drivers (like e.g. asix.c).

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

diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 2c1b8b6..29b1e03 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -339,6 +339,23 @@ int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
 	return result;
 }
 
+static void i2400mu_get_drvinfo(struct net_device *net_dev,
+                                struct ethtool_drvinfo *info)
+{
+	struct i2400m *i2400m = net_dev_to_i2400m(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);
+	usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
+}
+
+static const struct ethtool_ops i2400mu_ethtool_ops = {
+	.get_drvinfo = i2400mu_get_drvinfo,
+	.get_link = ethtool_op_get_link,
+};
 
 static
 void i2400mu_netdev_setup(struct net_device *net_dev)
@@ -347,6 +364,7 @@ void i2400mu_netdev_setup(struct net_device *net_dev)
 	struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
 	i2400mu_init(i2400mu);
 	i2400m_netdev_setup(net_dev);
+	net_dev->ethtool_ops = &i2400mu_ethtool_ops;
 }
 
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string
  2012-03-26 11:23 [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Phil Sutter
  2012-03-26 11:23 ` [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
  2012-03-26 14:57 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Ben Hutchings
@ 2012-03-28  2:30 ` David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-03-28  2:30 UTC (permalink / raw)
  To: phil.sutter; +Cc: netdev, inaky.perez-gonzalez

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops
  2012-03-26 11:23 ` [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
@ 2012-03-28  2:30   ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-03-28  2:30 UTC (permalink / raw)
  To: phil.sutter; +Cc: netdev, inaky.perez-gonzalez

From: Phil Sutter <phil.sutter@viprinet.com>
Date: Mon, 26 Mar 2012 13:23:56 +0200

> This way the USB variant of the driver uses usb_make_path in order to
> provide bus-info compatible to other USB drivers (like e.g. asix.c).
> 
> Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>

Applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-28  2:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-26 11:23 [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Phil Sutter
2012-03-26 11:23 ` [PATCH 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
2012-03-28  2:30   ` David Miller
2012-03-26 14:57 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string Ben Hutchings
2012-03-26 19:01   ` [PATCHv2 " Phil Sutter
2012-03-26 19:01     ` [PATCHv2 2/2] wimax: i2400m-usb - use a private struct ethtool_ops Phil Sutter
2012-03-28  2:30 ` [PATCH 1/2] wimax: i2400m - prevent a possible kernel bug due to missing fw_name string 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.