@@ -986,7 +986,6 @@ static int avdtp_send(struct bt_avdtp *session, struct net_buf *buf, struct bt_a
986
986
result = bt_l2cap_chan_send (& session -> br_chan .chan , buf );
987
987
if (result < 0 ) {
988
988
LOG_ERR ("Error:L2CAP send fail - result = %d" , result );
989
- net_buf_unref (buf );
990
989
bt_avdtp_clear_req (session );
991
990
return result ;
992
991
}
@@ -1306,6 +1305,7 @@ int bt_avdtp_init(void)
1306
1305
int bt_avdtp_discover (struct bt_avdtp * session , struct bt_avdtp_discover_params * param )
1307
1306
{
1308
1307
struct net_buf * buf ;
1308
+ int err ;
1309
1309
1310
1310
LOG_DBG ("" );
1311
1311
if (!param || !session ) {
@@ -1319,7 +1319,12 @@ int bt_avdtp_discover(struct bt_avdtp *session, struct bt_avdtp_discover_params
1319
1319
return - ENOMEM ;
1320
1320
}
1321
1321
1322
- return avdtp_send (session , buf , & param -> req );
1322
+ err = avdtp_send (session , buf , & param -> req );
1323
+ if (err ) {
1324
+ net_buf_unref (buf );
1325
+ }
1326
+
1327
+ return err ;
1323
1328
}
1324
1329
1325
1330
int bt_avdtp_parse_sep (struct net_buf * buf , struct bt_avdtp_sep_info * sep_info )
@@ -1345,6 +1350,7 @@ int bt_avdtp_get_capabilities(struct bt_avdtp *session,
1345
1350
struct bt_avdtp_get_capabilities_params * param )
1346
1351
{
1347
1352
struct net_buf * buf ;
1353
+ int err ;
1348
1354
1349
1355
LOG_DBG ("" );
1350
1356
if (!param || !session ) {
@@ -1362,7 +1368,12 @@ int bt_avdtp_get_capabilities(struct bt_avdtp *session,
1362
1368
/* Body of the message */
1363
1369
net_buf_add_u8 (buf , (param -> stream_endpoint_id << 2U ));
1364
1370
1365
- return avdtp_send (session , buf , & param -> req );
1371
+ err = avdtp_send (session , buf , & param -> req );
1372
+ if (err ) {
1373
+ net_buf_unref (buf );
1374
+ }
1375
+
1376
+ return err ;
1366
1377
}
1367
1378
1368
1379
int bt_avdtp_parse_capability_codec (struct net_buf * buf , uint8_t * codec_type ,
@@ -1433,6 +1444,7 @@ static int avdtp_process_configure_command(struct bt_avdtp *session, uint8_t cmd
1433
1444
struct bt_avdtp_set_configuration_params * param )
1434
1445
{
1435
1446
struct net_buf * buf ;
1447
+ int err ;
1436
1448
1437
1449
LOG_DBG ("" );
1438
1450
if (!param || !session ) {
@@ -1466,7 +1478,12 @@ static int avdtp_process_configure_command(struct bt_avdtp *session, uint8_t cmd
1466
1478
/* Codec Info Element */
1467
1479
net_buf_add_mem (buf , param -> codec_specific_ie , param -> codec_specific_ie_len );
1468
1480
1469
- return avdtp_send (session , buf , & param -> req );
1481
+ err = avdtp_send (session , buf , & param -> req );
1482
+ if (err ) {
1483
+ net_buf_unref (buf );
1484
+ }
1485
+
1486
+ return err ;
1470
1487
}
1471
1488
1472
1489
int bt_avdtp_set_configuration (struct bt_avdtp * session ,
@@ -1502,6 +1519,7 @@ static int bt_avdtp_ctrl(struct bt_avdtp *session, struct bt_avdtp_ctrl_params *
1502
1519
uint8_t check_state )
1503
1520
{
1504
1521
struct net_buf * buf ;
1522
+ int err ;
1505
1523
1506
1524
LOG_DBG ("" );
1507
1525
if (!param || !session || !param -> sep ) {
@@ -1523,7 +1541,12 @@ static int bt_avdtp_ctrl(struct bt_avdtp *session, struct bt_avdtp_ctrl_params *
1523
1541
/* ACP Stream Endpoint ID */
1524
1542
net_buf_add_u8 (buf , (param -> acp_stream_ep_id << 2U ));
1525
1543
1526
- return avdtp_send (session , buf , & param -> req );
1544
+ err = avdtp_send (session , buf , & param -> req );
1545
+ if (err ) {
1546
+ net_buf_unref (buf );
1547
+ }
1548
+
1549
+ return err ;
1527
1550
}
1528
1551
1529
1552
int bt_avdtp_open (struct bt_avdtp * session , struct bt_avdtp_ctrl_params * param )
0 commit comments