Skip to content

Commit 05c79b7

Browse files
gramsay0jgl-meta
authored andcommitted
canbus: isotp: Fix context buffer memory leaks
Ensure context buffers are free'd when errors occur Signed-off-by: Grant Ramsay <[email protected]>
1 parent 85788d2 commit 05c79b7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

subsys/canbus/isotp/isotp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ static int send(struct isotp_send_ctx *ctx, const struct device *can_dev,
11791179
ret = attach_fc_filter(ctx);
11801180
if (ret) {
11811181
LOG_ERR("Can't attach fc filter: %d", ret);
1182+
free_send_ctx(&ctx);
11821183
return ret;
11831184
}
11841185

@@ -1190,6 +1191,7 @@ static int send(struct isotp_send_ctx *ctx, const struct device *can_dev,
11901191
ctx->filter_id = -1;
11911192
ret = send_sf(ctx);
11921193
if (ret) {
1194+
free_send_ctx(&ctx);
11931195
return ret == -EAGAIN ?
11941196
ISOTP_N_TIMEOUT_A : ISOTP_N_ERROR;
11951197
}

0 commit comments

Comments
 (0)