Skip to content

Commit 6c9dc55

Browse files
jialu522hyson710
authored andcommitted
bluetooth: Fix resource leak issue.
bug: v/80614 When the family is not AF_LOCAL or AF_RPMSG, the function returns immediately without freeing the memory allocated for 'priv', leading to a memory leak. Signed-off-by: jialu <[email protected]>
1 parent cbea408 commit 6c9dc55

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

service/ipc/socket/src/bt_socket_client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ int bt_socket_async_client_init(bt_instance_t* ins, uv_loop_t* loop, int family,
715715
{
716716
int ret;
717717
bt_socket_async_client_t* priv;
718+
bt_status_t status = BT_STATUS_FAIL;
718719

719720
if (ins == NULL || loop == NULL)
720721
return BT_STATUS_PARM_INVALID;
@@ -757,7 +758,8 @@ int bt_socket_async_client_init(bt_instance_t* ins, uv_loop_t* loop, int family,
757758
}
758759
#endif
759760
else {
760-
return BT_STATUS_NOT_SUPPORTED;
761+
status = BT_STATUS_NOT_SUPPORTED;
762+
goto fail;
761763
}
762764
}
763765

@@ -766,7 +768,7 @@ int bt_socket_async_client_init(bt_instance_t* ins, uv_loop_t* loop, int family,
766768
return BT_STATUS_SUCCESS;
767769
fail:
768770
bt_socket_async_client_deinit(ins);
769-
return BT_STATUS_FAIL;
771+
return status;
770772
}
771773

772774
static void bt_socket_invoke_async_cb(bt_instance_t* ins, bt_list_t* list)

0 commit comments

Comments
 (0)