Re: [PATCH BlueZ] mesh: Fix application key binding lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Applied, Thanks.

On Tue, 2020-08-11 at 15:39 +0200, Michał Lowas-Rzechonek wrote:
> Because l_queue_find can't distinguish between entry->data equal to zero
> and missing entry, has_binding() fails when we bind app key with index
> 0, via L_UINT_TO_PTR.
> 
> Bug has been introduced in commit 1a2a6debd
> ---
>  mesh/model.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/mesh/model.c b/mesh/model.c
> index 4eaad31be..7d7f1551a 100644
> --- a/mesh/model.c
> +++ b/mesh/model.c
> @@ -140,7 +140,15 @@ static bool simple_match(const void *a, const void *b)
>  
>  static bool has_binding(struct l_queue *bindings, uint16_t idx)
>  {
> -	return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL;
> +	/* don't use l_queue_find, it can't distinguish between missing entry
> +	 * and entry with data equal to NULL */
> +	const struct l_queue_entry *entry;
> +
> +	for (entry = l_queue_get_entries(bindings); entry; entry = entry->next)
> +		if (L_PTR_TO_INT(entry->data) == idx)
> +			return true;
> +
> +	return false;
>  }
>  
>  static bool find_virt_by_label(const void *a, const void *b)




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux