mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: netdev@vger.kernel.org, timur@tabi.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: ogabbay@advaoptical.com, bigeasy@linutronix.de,
	Gerlando Falauto <gerlando.falauto@keymile.com>,
	"David S. Miller" <davem@davemloft.net>,
	Kumar Gala <galak@kernel.crashing.org>
Subject: [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range
Date: Mon, 12 Oct 2015 09:18:40 +0200	[thread overview]
Message-ID: <1444634321-14902-1-git-send-email-gerlando.falauto@keymile.com> (raw)
In-Reply-To: <1371041258-15298-1-git-send-email-ogabbay@advaoptical.com>

When configuring the MDIO subsystem it is also necessary to configure
the TBI register. Make sure the TBI is contained within the mapped
register range in order to:
a) make sure the address is computed correctly
b) make users aware that we're actually accessing that register

In case of error, print a message but continue anyway.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Timur Tabi <timur@tabi.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Kumar Gala <galak@kernel.crashing.org>
---
Changes from v1:
- Added type cast & fixed range
- removed freescale recipients

 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 3c40f6b..5333d0a 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -445,6 +445,16 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
 
 			tbipa = data->get_tbipa(priv->map);
 
+			/*
+			 * Add consistency check to make sure TBI is contained
+			 * within the mapped range (not because we would get a
+			 * segfault, rather to catch bugs in computing TBI
+			 * address). Print error message but continue anyway.
+			 */
+			if ((void *)tbipa > priv->map + resource_size(&res) - 4)
+				dev_err(&pdev->dev, "invalid register map (should be at least 0x%04x to contain TBI address)\n",
+					((void *)tbipa - priv->map) + 4);
+
 			iowrite32be(be32_to_cpup(prop), tbipa);
 		}
 	}
-- 
1.8.0.1


  parent reply	other threads:[~2015-10-12  7:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 12:47 [PATCH] MDIO: FSL_PQ_MDIO: Fix bug on incorrect offset of tbipa register Oded Gabbay
2013-06-12 13:04 ` Timur Tabi
2013-06-12 13:09   ` Oded Gabbay
2013-06-12 15:08 ` Sebastian Andrzej Siewior
2013-06-12 18:31   ` Scott Wood
2013-06-13  6:44     ` Oded Gabbay
2013-06-15 22:57     ` Timur Tabi
2015-10-09 15:15 ` [PATCH 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range Gerlando Falauto
2015-10-09 15:15   ` [PATCH 2/2] net/fsl_pq_mdio: fix computed address for the TBI register Gerlando Falauto
2015-10-09 17:39   ` [PATCH 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range kbuild test robot
2015-10-11 12:41   ` Timur Tabi
2015-10-12  7:18 ` Gerlando Falauto [this message]
2015-10-12  7:18   ` [PATCH v2 2/2] net/fsl_pq_mdio: fix computed address for the TBI register Gerlando Falauto
2015-10-13 11:30     ` David Miller
2015-10-13 11:30   ` [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range David Miller

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=1444634321-14902-1-git-send-email-gerlando.falauto@keymile.com \
    --to=gerlando.falauto@keymile.com \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=ogabbay@advaoptical.com \
    --cc=timur@tabi.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

all inboxes | Powered by JetHome®