Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1244437 > unrolled thread

[PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range

Started byGerlando Falauto <gerlando.falauto@keymile.com>
First post2015-10-12 09:30 +0200
Last post2015-10-13 13:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range Gerlando Falauto <gerlando.falauto@keymile.com> - 2015-10-12 09:30 +0200
    Re: [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for  consistency with mapped range David Miller <davem@davemloft.net> - 2015-10-13 13:20 +0200

#1244437 — [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range

FromGerlando Falauto <gerlando.falauto@keymile.com>
Date2015-10-12 09:30 +0200
Subject[PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range
Message-ID<qiFIu-pP-11@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1245601 — Re: [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range

FromDavid Miller <davem@davemloft.net>
Date2015-10-13 13:20 +0200
SubjectRe: [PATCH v2 1/2] net/fsl_pq_mdio: check TBI address for consistency with mapped range
Message-ID<qj5MC-4UT-29@gated-at.bofh.it>
In reply to#1244437
From: Gerlando Falauto <gerlando.falauto@keymile.com>
Date: Mon, 12 Oct 2015 09:18:40 +0200

> 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

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web