[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090803175733.GD28606@sortiz.org>
Date: Mon, 3 Aug 2009 19:57:34 +0200
From: Samuel Ortiz <sameo@...ux.intel.com>
To: Paul Fertser <fercerpav@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pcf50633: revise locking for ADC
Hi Paul,
On Tue, Jul 28, 2009 at 12:58:48AM +0400, Paul Fertser wrote:
> Current implementation is prone to races, this patch attempts to remove all
> but one (in pcf50633_adc_sync_read).
>
> The idea is that we need to guard the queue access only on inserting and
> removing items. If we insert and there're no more items in the queue it
> means that the last irq already happened and we need to trigger ADC
> manually. If not, then the next conversion will be triggered by the irq
> handler upon completion of the previous.
> @@ -136,9 +133,13 @@ int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
> req->callback_param = req;
>
> init_completion(&req->completion);
> - adc_enqueue_request(pcf, req);
> + err = adc_enqueue_request(pcf, req);
> + if (err)
> + return err;
> +
> wait_for_completion(&req->completion);
>
> + /* FIXME by this time req might be already freed */
In fact, this is problematic.
Shouldn't the request be freed by the callback (in the async request), or by
sync_read() ?
Your patch looks fine though, I applied it to my for-next branch.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists