@@ -1251,7 +1251,10 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp)
12511251
12521252 info = net_buf_add (buf , sizeof (* info ));
12531253
1254- bt_rand (info -> csrk , sizeof (info -> csrk ));
1254+ if (bt_rand (info -> csrk , sizeof (info -> csrk ))) {
1255+ BT_ERR ("Unable to get random bytes" );
1256+ return ;
1257+ }
12551258
12561259 if (atomic_test_bit (smp -> flags , SMP_FLAG_BOND )) {
12571260 bt_keys_add_type (keys , BT_KEYS_LOCAL_CSRK );
@@ -2048,7 +2051,10 @@ static void legacy_distribute_keys(struct bt_smp *smp)
20482051 uint8_t ediv [2 ];
20492052 } rand ;
20502053
2051- bt_rand ((void * )& rand , sizeof (rand ));
2054+ if (bt_rand ((void * )& rand , sizeof (rand ))) {
2055+ BT_ERR ("Unable to get random bytes" );
2056+ return ;
2057+ }
20522058
20532059 buf = smp_create_pdu (smp , BT_SMP_CMD_ENCRYPT_INFO ,
20542060 sizeof (* info ));
@@ -2158,7 +2164,9 @@ static uint8_t bt_smp_distribute_keys(struct bt_smp *smp)
21582164
21592165 info = net_buf_add (buf , sizeof (* info ));
21602166
2161- bt_rand (info -> csrk , sizeof (info -> csrk ));
2167+ if (bt_rand (info -> csrk , sizeof (info -> csrk ))) {
2168+ return BT_SMP_ERR_UNSPECIFIED ;
2169+ }
21622170
21632171 if (atomic_test_bit (smp -> flags , SMP_FLAG_BOND )) {
21642172 bt_keys_add_type (keys , BT_KEYS_LOCAL_CSRK );
0 commit comments