0179-Protect-__release_resource-against-resources-without.patch 740 B

123456789101112131415161718192021222324252627
  1. From a58c105dfd13e0ba54a1124d0aad81d9c25f85e3 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Fri, 13 Mar 2015 12:43:36 +0000
  4. Subject: [PATCH] Protect __release_resource against resources without parents
  5. Without this patch, removing a device tree overlay can crash here.
  6. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  7. ---
  8. kernel/resource.c | 6 ++++++
  9. 1 file changed, 6 insertions(+)
  10. --- a/kernel/resource.c
  11. +++ b/kernel/resource.c
  12. @@ -246,6 +246,12 @@ static int __release_resource(struct res
  13. {
  14. struct resource *tmp, **p;
  15. + if (!old->parent) {
  16. + WARN(old->sibling, "sibling but no parent");
  17. + if (old->sibling)
  18. + return -EINVAL;
  19. + return 0;
  20. + }
  21. p = &old->parent->child;
  22. for (;;) {
  23. tmp = *p;