Skip to content

Commit 3f73100

Browse files
committed
free partial operator on alloc failure in create paths
1 parent 697543f commit 3f73100

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/operators/binary-elementwise-nd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ enum xnn_status xnn_create_binary_elementwise_nd(
247247
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
248248
sizeof(struct compute_parameters),
249249
xnn_binary_operator_to_string(type));
250+
xnn_delete_operator(op);
250251
return xnn_status_out_of_memory;
251252
}
252253
op->num_compute_invocations = 1;

src/operators/pack-lh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ enum xnn_status create_pack_lh(uint32_t flags,
5252
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
5353
sizeof(struct compute_parameters),
5454
xnn_operator_type_to_string(expected_operator_type));
55+
xnn_delete_operator(pack_lh_op);
5556
return xnn_status_out_of_memory;
5657
}
5758
pack_lh_op->num_compute_invocations = 1;

src/operators/resize-bilinear-nhwc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum xnn_status xnn_create_resize_bilinear2d_nhwc(
9090
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
9191
sizeof(struct compute_parameters),
9292
xnn_operator_type_to_string(xnn_operator_type_resize_bilinear_nhwc));
93+
xnn_delete_operator(resize_op);
9394
return xnn_status_out_of_memory;
9495
}
9596
resize_op->num_compute_invocations = num_compute_invocations;
@@ -98,6 +99,7 @@ enum xnn_status xnn_create_resize_bilinear2d_nhwc(
9899
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
99100
sizeof(struct xnn_convolution_operator),
100101
xnn_operator_type_to_string(xnn_operator_type_resize_bilinear_nhwc));
102+
xnn_delete_operator(resize_op);
101103
return xnn_status_out_of_memory;
102104
}
103105

src/operators/unary-elementwise-nc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ enum xnn_status xnn_create_unary_elementwise_nc(
348348
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
349349
sizeof(struct compute_parameters),
350350
xnn_unary_operator_to_string(op_type));
351+
xnn_delete_operator(op);
351352
return xnn_status_out_of_memory;
352353
}
353354
op->num_compute_invocations = num_compute_invocations;
@@ -637,6 +638,7 @@ static enum xnn_status create_unary_elementwise_nc(
637638
xnn_log_error("failed to allocate %zu bytes for %s operator descriptor",
638639
sizeof(struct compute_parameters),
639640
xnn_operator_type_to_string(operator_type));
641+
xnn_delete_operator(unary_elementwise_op);
640642
return xnn_status_out_of_memory;
641643
}
642644
unary_elementwise_op->num_compute_invocations = num_compute_invocations;

0 commit comments

Comments
 (0)