All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/nfp: check BAR size is above a safe size
@ 2017-11-08 12:28 Alejandro Lucero
  2017-11-10  9:39 ` [dpdk-stable] " Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Lucero @ 2017-11-08 12:28 UTC (permalink / raw)
  To: dev; +Cc: stable

We do not know how big can the BAR be, but we know anything less
than 1MB is an error. This BAR needs to be big enough for accessing
most of NFP internals.

Fixes: d12206e00590 ("net/nfp: add NSP user space interface")
Coverity: 195024

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfp_nfpu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/nfp/nfp_nfpu.c b/drivers/net/nfp/nfp_nfpu.c
index 5775d8d..f11afef 100644
--- a/drivers/net/nfp/nfp_nfpu.c
+++ b/drivers/net/nfp/nfp_nfpu.c
@@ -75,8 +75,13 @@
 	/* barsz in log2 */
 	while (barsz >>= 1)
 		i++;
+
 	barsz = i;
 
+	/* Sanity check: we can assume any bar size less than 1MB an error */
+	if (barsz < 20)
+		return -1;
+
 	/* Getting address for NFP expansion BAR registers */
 	cfg_base = pci_dev->mem_resource[0].addr;
 	cfg_base = (uint8_t *)cfg_base + NFP_CFG_EXP_BAR_CFG_BASE;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH] net/nfp: check BAR size is above a safe size
  2017-11-08 12:28 [PATCH] net/nfp: check BAR size is above a safe size Alejandro Lucero
@ 2017-11-10  9:39 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2017-11-10  9:39 UTC (permalink / raw)
  To: Alejandro Lucero, dev; +Cc: stable

On 11/8/2017 4:28 AM, Alejandro Lucero wrote:
> We do not know how big can the BAR be, but we know anything less
> than 1MB is an error. This BAR needs to be big enough for accessing
> most of NFP internals.
> 
> Fixes: d12206e00590 ("net/nfp: add NSP user space interface")
> Coverity: 195024
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>

Applied to dpdk/master, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-10  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 12:28 [PATCH] net/nfp: check BAR size is above a safe size Alejandro Lucero
2017-11-10  9:39 ` [dpdk-stable] " Ferruh Yigit

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.