linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Bordug <vbordug@ru.mvista.com>
To: linuxppc-dev <linuxppc-dev@ozlabs.org>
Subject: [PATCH 4/6] FS_ENET: phydev pointer may be dereferenced without NULL check
Date: Sat, 24 Jun 2006 03:17:04 +0400	[thread overview]
Message-ID: <20060623231704.6721.85445.stgit@localhost.localdomain> (raw)
In-Reply-To: <20060623231648.6721.3495.stgit@localhost.localdomain>


When interface is down, phy is "disconnected" from the bus and phydev is NULL.
But ethtool may try to get/set phy regs even at that time, which results in
NULL pointer dereference and OOPS hereby.

Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
---

 drivers/net/fs_enet/fs_enet-main.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 302ecaa..e475e22 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -882,12 +882,16 @@ static void fs_get_regs(struct net_devic
 static int fs_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
+	if (!fep->phydev)
+		return -EINVAL;
 	return phy_ethtool_gset(fep->phydev, cmd);
 }
 
 static int fs_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
 	struct fs_enet_private *fep = netdev_priv(dev);
+	if (!fep->phydev)
+		return -EINVAL;
 	phy_ethtool_sset(fep->phydev, cmd);
 	return 0;
 }

  parent reply	other threads:[~2006-06-23 23:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060623231648.6721.3495.stgit@localhost.localdomain>
2006-06-23 23:16 ` [PATCH 1/6] PAL: Support of the fixed PHY Vitaly Bordug
2006-06-23 23:16 ` [PATCH 2/6] FS_ENET: Utilize Phy abstraction Vitaly Bordug
2006-06-23 23:17 ` [PATCH 3/6] FS_ENET: use PAL for mii management (BSP part) Vitaly Bordug
2006-06-23 23:17 ` Vitaly Bordug [this message]
2006-06-23 23:17 ` [PATCH 5/6] CPM_UART: unify clock sources Vitaly Bordug
2006-06-24 13:46   ` Kumar Gala
2006-06-24 15:21     ` Vitaly Bordug
2006-06-24 15:50       ` Kumar Gala
2006-06-24 16:22       ` Jon Loeliger
2006-06-24 16:27         ` Kumar Gala
2006-06-23 23:17 ` [PATCH 6/6] [RFC] POWERPC: Add mpc8560 board support Vitaly Bordug
2006-06-24 16:26   ` Kumar Gala
2006-06-24 17:17     ` Vitaly Bordug
2006-06-26 13:35       ` Kumar Gala

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=20060623231704.6721.85445.stgit@localhost.localdomain \
    --to=vbordug@ru.mvista.com \
    --cc=linuxppc-dev@ozlabs.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).