26
26
#include <linux/kernel.h>
27
27
#include <linux/string.h>
28
28
#include <subcmd/exec-cmd.h>
29
+ #include <linux/zalloc.h>
29
30
30
31
static bool dont_fork ;
31
32
@@ -540,7 +541,7 @@ static int shell_tests__max_desc_width(void)
540
541
{
541
542
struct dirent * * entlist ;
542
543
struct dirent * ent ;
543
- int n_dirs ;
544
+ int n_dirs , e ;
544
545
char path_dir [PATH_MAX ];
545
546
const char * path = shell_tests__dir (path_dir , sizeof (path_dir ));
546
547
int width = 0 ;
@@ -564,8 +565,9 @@ static int shell_tests__max_desc_width(void)
564
565
}
565
566
}
566
567
568
+ for (e = 0 ; e < n_dirs ; e ++ )
569
+ zfree (& entlist [e ]);
567
570
free (entlist );
568
-
569
571
return width ;
570
572
}
571
573
@@ -596,7 +598,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width)
596
598
{
597
599
struct dirent * * entlist ;
598
600
struct dirent * ent ;
599
- int n_dirs ;
601
+ int n_dirs , e ;
600
602
char path_dir [PATH_MAX ];
601
603
struct shell_test st = {
602
604
.dir = shell_tests__dir (path_dir , sizeof (path_dir )),
@@ -629,6 +631,8 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width)
629
631
test_and_print (& test , false, -1 );
630
632
}
631
633
634
+ for (e = 0 ; e < n_dirs ; e ++ )
635
+ zfree (& entlist [e ]);
632
636
free (entlist );
633
637
return 0 ;
634
638
}
@@ -730,7 +734,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i)
730
734
{
731
735
struct dirent * * entlist ;
732
736
struct dirent * ent ;
733
- int n_dirs ;
737
+ int n_dirs , e ;
734
738
char path_dir [PATH_MAX ];
735
739
const char * path = shell_tests__dir (path_dir , sizeof (path_dir ));
736
740
@@ -752,8 +756,11 @@ static int perf_test__list_shell(int argc, const char **argv, int i)
752
756
continue ;
753
757
754
758
pr_info ("%2d: %s\n" , i , t .desc );
759
+
755
760
}
756
761
762
+ for (e = 0 ; e < n_dirs ; e ++ )
763
+ zfree (& entlist [e ]);
757
764
free (entlist );
758
765
return 0 ;
759
766
}
0 commit comments