diff mbox series

net: dsa: mv88e6xxx: Fix memleak in mv88e6xxx_region_atu_snapshot

Message ID 20201109144416.1540867-1-zhangxiaoxu5@huawei.com
State Accepted
Delegated to: David Miller
Headers show
Series net: dsa: mv88e6xxx: Fix memleak in mv88e6xxx_region_atu_snapshot | expand

Checks

Context Check Description
jkicinski/cover_letter success Link
jkicinski/fixes_present success Link
jkicinski/patch_count success Link
jkicinski/tree_selection success Guessed tree name to be net-next
jkicinski/subject_prefix warning Target tree name not specified in the subject
jkicinski/source_inline success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/module_param success Was 0 now: 0
jkicinski/build_32bit success Errors and warnings before: 0 this patch: 0
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/verify_fixes success Link
jkicinski/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
jkicinski/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
jkicinski/header_inline success Link
jkicinski/stable success Stable not CCed

Commit Message

zhangxiaoxu (A) Nov. 9, 2020, 2:44 p.m. UTC
When mv88e6xxx_fid_map return error, we lost free the table.

Fix it.

Fixes: bfb255428966 ("net: dsa: mv88e6xxx: Add devlink regions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhangxiaoxu <zhangxiaoxu5@huawei.com>
---
 drivers/net/dsa/mv88e6xxx/devlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Nov. 9, 2020, 2:46 p.m. UTC | #1
On Mon, Nov 09, 2020 at 09:44:16AM -0500, zhangxiaoxu wrote:
> When mv88e6xxx_fid_map return error, we lost free the table.
> 
> Fix it.
> 
> Fixes: bfb255428966 ("net: dsa: mv88e6xxx: Add devlink regions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhangxiaoxu <zhangxiaoxu5@huawei.com>

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

    Andrew
Jakub Kicinski Nov. 11, 2020, 1:50 a.m. UTC | #2
On Mon, 9 Nov 2020 15:46:57 +0100 Andrew Lunn wrote:
> On Mon, Nov 09, 2020 at 09:44:16AM -0500, zhangxiaoxu wrote:
> > When mv88e6xxx_fid_map return error, we lost free the table.
> > 
> > Fix it.
> > 
> > Fixes: bfb255428966 ("net: dsa: mv88e6xxx: Add devlink regions")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: zhangxiaoxu <zhangxiaoxu5@huawei.com>  
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c
index 10cd1bfd81a0..ade04c036fd9 100644
--- a/drivers/net/dsa/mv88e6xxx/devlink.c
+++ b/drivers/net/dsa/mv88e6xxx/devlink.c
@@ -393,8 +393,10 @@  static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 	mv88e6xxx_reg_lock(chip);
 
 	err = mv88e6xxx_fid_map(chip, fid_bitmap);
-	if (err)
+	if (err) {
+		kfree(table);
 		goto out;
+	}
 
 	while (1) {
 		fid = find_next_bit(fid_bitmap, MV88E6XXX_N_FID, fid + 1);