Skip to content

Commit cdbdfca

Browse files
Phil Elwellpopcornmix
authored andcommitted
Protect __release_resource against resources without parents
Without this patch, removing a device tree overlay can crash here. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
1 parent e9fa43c commit cdbdfca

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎kernel/resource.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ static int __release_resource(struct resource *old, bool release_child)
214214
{
215215
struct resource *tmp, **p, *chd;
216216

217+
if (!old->parent) {
218+
WARN(old->sibling, "sibling but no parent");
219+
if (old->sibling)
220+
return -EINVAL;
221+
return 0;
222+
}
217223
p = &old->parent->child;
218224
for (;;) {
219225
tmp = *p;

0 commit comments

Comments
 (0)