All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: "Roger Luethi" <rl@hellgate.ch>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ethtool: __ethtool_set_sg: check for function pointer before using it
Date: Thu, 17 Mar 2011 16:52:13 +0000	[thread overview]
Message-ID: <1300380733.2569.3.camel@bwh-desktop> (raw)
In-Reply-To: <20110317163720.GA26284@core.hellgate.ch>

On Thu, 2011-03-17 at 17:37 +0100, Roger Luethi wrote:
> __ethtool_set_sg does not check if dev->ethtool_ops->set_sg is defined
> which can result in a NULL pointer dereference when ethtool is used to
> change SG settings for drivers without SG support.
> 
> Signed-off-by: Roger Luethi <rl@hellgate.ch>
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>

Michał, was this just an oversight or is there some reason why we
shouldn't check set_sg immediately?

Ben.

> ---
> 
> Bug verified. Patch only compile-tested.
>
>  net/core/ethtool.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index c1a71bb..a1086fb 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -1457,6 +1457,9 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
>  {
>  	int err;
>  
> +	if (!dev->ethtool_ops->set_sg)
> +		return -EOPNOTSUPP;
> +
>  	if (data && !(dev->features & NETIF_F_ALL_CSUM))
>  		return -EINVAL;
>  

-- 
Ben Hutchings, Senior Software 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.


  reply	other threads:[~2011-03-17 16:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 16:37 [PATCH] ethtool: __ethtool_set_sg: check for function pointer before using it Roger Luethi
2011-03-17 16:52 ` Ben Hutchings [this message]
2011-03-18 22:15   ` David Miller
2011-03-17 17:00 ` Michał Mirosław

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300380733.2569.3.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=rl@hellgate.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.