827-v6.3-0005-of-device-Do-not-ignore-error-code-in-of_device_ueve.patch 1.1 KB

1234567891011121314151617181920212223242526272829
  1. From 2295bed9bebe8d1eef276194fed5b5fbe89c5363 Mon Sep 17 00:00:00 2001
  2. From: Alexander Stein <[email protected]>
  3. Date: Tue, 7 Feb 2023 12:05:30 +0100
  4. Subject: [PATCH] of: device: Do not ignore error code in
  5. of_device_uevent_modalias
  6. of_device_get_modalias might return an error code, propagate that one.
  7. Otherwise the negative, signed integer is propagated to unsigned integer
  8. for the comparison resulting in a huge 'sl' size.
  9. Signed-off-by: Alexander Stein <[email protected]>
  10. Reviewed-by: Rob Herring <[email protected]>
  11. Link: https://lore.kernel.org/r/[email protected]
  12. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  13. ---
  14. drivers/of/device.c | 2 ++
  15. 1 file changed, 2 insertions(+)
  16. --- a/drivers/of/device.c
  17. +++ b/drivers/of/device.c
  18. @@ -381,6 +381,8 @@ int of_device_uevent_modalias(struct dev
  19. sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
  20. sizeof(env->buf) - env->buflen);
  21. + if (sl < 0)
  22. + return sl;
  23. if (sl >= (sizeof(env->buf) - env->buflen))
  24. return -ENOMEM;
  25. env->buflen += sl;