diff mbox series

[net-next,2/3] net: dsa: mv88e6xxx: Fix off-by-one in VTU devlink region size

Message ID 20210421120454.1541240-3-tobias@waldekranz.com (mailing list archive)
State Accepted
Commit 281140a0a2ce4febf2c0ce5d29d0e7d961a826b1
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: mv88e6xxx: Tiny fixes/improvements | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Tobias Waldekranz April 21, 2021, 12:04 p.m. UTC
In the unlikely event of the VTU being loaded to the brim with 4k
entries, the last one was placed in the buffer, but the size reported
to devlink was off-by-one. Make sure that the final entry is available
to the caller.

Fixes: ca4d632aef03 ("net: dsa: mv88e6xxx: Export VTU as devlink region")
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
 drivers/net/dsa/mv88e6xxx/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn April 21, 2021, 12:23 p.m. UTC | #1
On Wed, Apr 21, 2021 at 02:04:53PM +0200, Tobias Waldekranz wrote:
> In the unlikely event of the VTU being loaded to the brim with 4k
> entries, the last one was placed in the buffer, but the size reported
> to devlink was off-by-one. Make sure that the final entry is available
> to the caller.
> 
> Fixes: ca4d632aef03 ("net: dsa: mv88e6xxx: Export VTU as devlink region")
> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>

The snapshot code gets it right, but not this :-(

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c
index 21953d6d484c..ada7a38d4d31 100644
--- a/drivers/net/dsa/mv88e6xxx/devlink.c
+++ b/drivers/net/dsa/mv88e6xxx/devlink.c
@@ -678,7 +678,7 @@  static int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds,
 				sizeof(struct mv88e6xxx_devlink_atu_entry);
 			break;
 		case MV88E6XXX_REGION_VTU:
-			size = mv88e6xxx_max_vid(chip) *
+			size = (mv88e6xxx_max_vid(chip) + 1) *
 				sizeof(struct mv88e6xxx_devlink_vtu_entry);
 			break;
 		}