Skip to content

Commit

Permalink
resources: tidy __request_region()
Browse files Browse the repository at this point in the history
No functional change.  Just return NULL for kzalloc failure immediately,
rather than wrapping the whole function body in the body of an "if".

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Bjorn Helgaas authored and torvalds committed Oct 16, 2008
1 parent 923f7f6 commit c26ec88
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,33 +630,34 @@ struct resource * __request_region(struct resource *parent,
{
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);

if (res) {
res->name = name;
res->start = start;
res->end = start + n - 1;
res->flags = IORESOURCE_BUSY;
if (!res)
return NULL;

write_lock(&resource_lock);
res->name = name;
res->start = start;
res->end = start + n - 1;
res->flags = IORESOURCE_BUSY;

for (;;) {
struct resource *conflict;
write_lock(&resource_lock);

conflict = __request_resource(parent, res);
if (!conflict)
break;
if (conflict != parent) {
parent = conflict;
if (!(conflict->flags & IORESOURCE_BUSY))
continue;
}
for (;;) {
struct resource *conflict;

/* Uhhuh, that didn't work out.. */
kfree(res);
res = NULL;
conflict = __request_resource(parent, res);
if (!conflict)
break;
if (conflict != parent) {
parent = conflict;
if (!(conflict->flags & IORESOURCE_BUSY))
continue;
}
write_unlock(&resource_lock);

/* Uhhuh, that didn't work out.. */
kfree(res);
res = NULL;
break;
}
write_unlock(&resource_lock);
return res;
}
EXPORT_SYMBOL(__request_region);
Expand Down

0 comments on commit c26ec88

Please sign in to comment.