disk/ieee1275 : Add a fix for memory leaks in ofdisk
PATCH 1/1 disk/ieee1275 : Add a fix for memory leaks in ofdisk
Adding a fix for memory leaks. In case of overflow check fails, not freeing 'p' and 'p->grub_devpath' will result in memory leaks.
--- grub-core/disk/ieee1275/ofdisk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
grub-core/disk/ieee1275/ofdisk.c +5 -2
@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath) grub_add (sz, sizeof ("ieee1275/"), &sz)) {grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of device path" )); +grub_free (p);return NULL ; }
@@ -108,8 +109,10 @@ ofdisk_hash_add_real (char *devpath) {if (grub_add (grub_strlen (p->devpath),3 , &sz)) { -grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path" )); -return NULL ; +grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path" )); +grub_free (p->grub_devpath); +grub_free (p); +return NULL ; } p->open_path =grub_malloc (sz);
Signature · 7 lines
2.52.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 35 lines · Avnish Chouhan
Adding a fix for memory leaks. In case of overflow check fails, not freeing 'p' and 'p-
Quoted 1 line
grub_devpath' will result in memory leaks.Signed-off-by Avnish Chouhan <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)grub-core/disk/ieee1275/ofdisk.c +5
-2@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath) grub_add (sz, sizeof ("ieee1275/"), &sz)) {grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of device path")); +grub_free (p);return NULL ; }@@ -108,8 +109,10 @@ ofdisk_hash_add_real (char *devpath) {if (grub_add (grub_strlen (p->devpath),3 , &sz)) { -grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path")); -return NULL ; + grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path")); + grub_free (p->grub_devpath); + grub_free (p); +return NULL ; }
Quoted 3 lines
p->open_path = grub_malloc (sz);--
2.52.0
LGTM! Thanks!
Alec Brown
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Daniel Kiper
Reviewed-byQuoted 36 lines · Alec Brown via Grub-devel
Quoted 35 lines · Avnish Chouhan
Adding a fix for memory leaks. In case of overflow check fails, not freeing 'p' and 'p-
Quoted 1 line
grub_devpath' will result in memory leaks.Signed-off-by Avnish Chouhan <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)grub-core/disk/ieee1275/ofdisk.c +5
-2@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath) grub_add (sz, sizeof ("ieee1275/"), &sz)) {grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of device path")); +grub_free (p);return NULL ; }@@ -108,8 +109,10 @@ ofdisk_hash_add_real (char *devpath) {if (grub_add (grub_strlen (p->devpath),3 , &sz)) { -grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path")); -return NULL ; + grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path")); + grub_free (p->grub_devpath); + grub_free (p); +return NULL ; }
Quoted 7 lines
Quoted 3 lines
p->open_path = grub_malloc (sz);--
2.52.0LGTM! Thanks!
Reviewed-by Alec Brown <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 8 lines · Avnish Chouhan
Adding a fix for memory leaks. In case of overflow check fails, not freeing 'p' and '
p->grub_devpath' will result in memory leaks.Signed-off-by Avnish Chouhan <[email protected]>
Thanks,
Sudhakar
Quoted 37 lines
---
grub-core/disk/ieee1275/ofdisk.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)grub-core/disk/ieee1275/ofdisk.c +5
-2@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath) grub_add (sz, sizeof ("ieee1275/"), &sz)) {grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of device path" )); +grub_free (p);return NULL ; }@@ -108,8 +109,10 @@ ofdisk_hash_add_real (char *devpath) {if (grub_add (grub_strlen (p->devpath),3 , &sz)) { -grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path" )); -return NULL ; +grub_error (GRUB_ERR_OUT_OF_RANGE ,N_ ("overflow detected while obtaining size of an open path" )); +grub_free (p->grub_devpath); +grub_free (p); +return NULL ; } p->open_path =grub_malloc (sz);Signature · 7 lines
2.52.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel