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

12345678910111213141516171819202122232425262728
  1. From e48f4b37e5fbb039bee4fde22469f383cc98a1d8 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 179/381] Protect __release_resource against resources without
  5. parents
  6. Without this patch, removing a device tree overlay can crash here.
  7. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  8. ---
  9. kernel/resource.c | 6 ++++++
  10. 1 file changed, 6 insertions(+)
  11. --- a/kernel/resource.c
  12. +++ b/kernel/resource.c
  13. @@ -237,6 +237,12 @@ static int __release_resource(struct res
  14. {
  15. struct resource *tmp, **p;
  16. + if (!old->parent) {
  17. + WARN(old->sibling, "sibling but no parent");
  18. + if (old->sibling)
  19. + return -EINVAL;
  20. + return 0;
  21. + }
  22. p = &old->parent->child;
  23. for (;;) {
  24. tmp = *p;