Re: [PATCH][RFC] Fix SDP resolving segfault

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

 



Hi Manuel,

On Tue, Jul 20, 2010, Manuel Naranjo wrote:
> I think this patch fixes the weird segfault I had been experiencing
> for the last few months.

Thanks for the patch proposal. It seems like you're trying to to fix the
issue by doing all sorts of minor tweaks here and there, i.e. it seems
like there isn't a full understanding of the real root cause.

> -	if (ctxt->cb)
> +	if (ctxt->cb && ctxt->user_data)
>  		ctxt->cb(recs, err, ctxt->user_data);

This part isn't right. It should be perfectly fine for a discovery
requester to pass NULL as user_data and still expect its callback to get
called.

> -		if (ctxt->cb)
> +		if (ctxt->cb && ctxt->user_data)
>  			ctxt->cb(NULL, err, ctxt->user_data);

Same here.

> @@ -254,6 +256,8 @@ static gboolean connect_watch(GIOChannel *chan, GIOCondition cond, gpointer user
>  	int sk, err = 0;
>  
>  	sk = g_io_channel_unix_get_fd(chan);
> +	if (ctxt->io_id)
> +	    g_source_remove(ctxt->io_id);

connect_watch returns FALSE in all cases which will remove the GSource.
So the change you're doing seems redundant.

> -	if (ctxt->cb)
> +	if (ctxt->cb && ctxt->user_data)
>  		ctxt->cb(NULL, -err, ctxt->user_data);

Same issue with NULL user_data being valid.

> @@ -391,11 +395,13 @@ int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
>  		return -ENODATA;
>  
>  	ctxt = match->data;
> -	if (!ctxt->session)
> -		return -ENOTCONN;
>  
>  	if (ctxt->io_id)
>  		g_source_remove(ctxt->io_id);
> +	ctxt->io_id = 0;
> +
> +	if (!ctxt->session)
> +		return -ENOTCONN;
>  
>  	if (ctxt->session)
>  		sdp_close(ctxt->session);

I don't really understand the need for these changes, but admitedly the
function does have issues since it first checks for !ctxt->session and
then later for ctxt->session even though at that point it's already
guaranteed that ctxt->session is not NULL.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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