lkml.org 
[lkml]   [2012]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver core: check 'start' argument in bus iterators
On 04/16/2012 01:51 PM, Kay Sievers wrote:
> On Mon, Apr 16, 2012 at 12:48, Hannes Reinecke <hare@suse.de> wrote:
>> bus_for_each_dev() and bus_find_device() both take a 'start'
>> argument to start the iteration at a specific list entry.
>> However, this list entry might already been detached by
>> the time these functions are called.
>> So we need to check if the arguments are still valid.
>
>> + if (start && !klist_node_attached(&start->p->knode_bus))
>> + return -ENODEV;
>> +
>> klist_iter_init_node(&bus->p->klist_devices, &i,
>> (start ? &start->p->knode_bus : NULL));
>
> Shouldn't we do this check in klist_iter_init_node()?
> After a kref_get(), and return -ENODEV from there if the node it as
> asked to start is gone?
>
Sure, if you prefer.

> This check otherwise still has the window between the check and the
> use of it, only very unlikely to hit now, hasn't it?
>
yeah, very.
The iteration itself could take some time (locks etc), but the race
between those two lines is really tiny.

But yeah, for the sake of correctness, we should.

I'll be sending an updated patch.

Cheers,

Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-04-16 14:13    [W:0.037 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site