netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Mike McCormack <mikem@ring3k.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] sky2: Make hw->ports the number of ports allocated
Date: Fri, 11 Sep 2009 21:43:58 -0700	[thread overview]
Message-ID: <20090911214358.7096f544@nehalam> (raw)
In-Reply-To: <4AAB133B.8070900@ring3k.org>

On Sat, 12 Sep 2009 12:19:23 +0900
Mike McCormack <mikem@ring3k.org> wrote:

> If allocation of the second ports fails, make sure that hw->ports
>  is not 2 otherwise we'll crash trying to access the second port.
> 
> Signed-off-by: Mike McCormack <mikem@ring3k.org>
> ---
>  drivers/net/sky2.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
> index 018aa58..c17ee26 100644
> --- a/drivers/net/sky2.c
> +++ b/drivers/net/sky2.c
> @@ -4563,6 +4563,10 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
>  			free_netdev(dev1);
>  		} else
>  			sky2_show_addr(dev1);
> +
> +		/* couldn't allocate the second port */
> +		if (!hw->dev[1])
> +			--hw->ports;
>  	}
>  
>  	setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw);

If it couldn't allocate the port, would be better to unwind the first port
and fail the probe, rather than silently failing in a really sick system.

-- 

      reply	other threads:[~2009-09-12  4:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-12  3:19 [PATCH] sky2: Make hw->ports the number of ports allocated Mike McCormack
2009-09-12  4:43 ` Stephen Hemminger [this message]

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=20090911214358.7096f544@nehalam \
    --to=shemminger@linux-foundation.org \
    --cc=mikem@ring3k.org \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).