[nft PATCH] Fix memleak in netlink_parse_fwd() error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure allocated 'stmt' is freed before returning to caller.

Fixes: 30d45266bf38b ("expr: extend fwd statement to support address and family")
Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/netlink_delinearize.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 0a6ebe05ca7ca..cd058850f4df0 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -1227,9 +1227,11 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
 		reg2 = netlink_parse_register(nle, NFTNL_EXPR_FWD_SREG_ADDR);
 		if (reg2) {
 			addr = netlink_get_register(ctx, loc, reg2);
-			if (addr == NULL)
-				return netlink_error(ctx, loc,
-						     "fwd statement has no output expression");
+			if (addr == NULL) {
+				netlink_error(ctx, loc,
+					      "fwd statement has no output expression");
+				goto out_err;
+			}
 
 			switch (stmt->fwd.family) {
 			case AF_INET:
@@ -1241,8 +1243,9 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
 					      BYTEORDER_BIG_ENDIAN);
 				break;
 			default:
-				return netlink_error(ctx, loc,
-						     "fwd statement has no family");
+				netlink_error(ctx, loc,
+					      "fwd statement has no family");
+				goto out_err;
 			}
 			stmt->fwd.addr = addr;
 		}
-- 
2.19.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux