scripts: small fixes
cover scripts: small fixes
[PATCH 1/2] scripts: genksyms: fix resource leak [PATCH 2/2] scripts: dtc: fix memory leak after realloc
PATCH 1/2 scripts: genksyms: fix resource leak
This commit fixed resource leak at func main
--- scripts/genksyms/genksyms.c | 3 +++ 1 file changed, 3 insertions(+)
scripts/genksyms/genksyms.c +3 -0
@@ -873,5 +873,8 @@ int main(int argc, char **argv) (double)nsyms / (double)HASH_BUCKETS); } +if (dumpfile) +fclose (dumpfile); +return errors !=0 ; }
Signature · 1 line
2.7.1.1.g3617aa0
PATCH 2/2 scripts: dtc: fix memory leak after realloc
In reply to Maxim ZhukovThis commit fixed memory leak after errors realloc.
--- scripts/dtc/fdtput.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
scripts/dtc/fdtput.c +7 -3
@@ -75,8 +75,9 @@ static int encode_value(struct display_info *disp, char **arg, int arg_count,char *ptr;/* pointer to current value position */ int len;/* length of this cell/string/byte */ int ival; -int upto;/* the number of bytes we have written to buf */ +int upto;/* the number of bytes we have written to buf */ char fmt[3 ]; +void *save_ptr =NULL ;/* save pointer to realloc */ upto =0 ;
@@ -96,12 +97,15 @@ static int encode_value(struct display_info *disp, char **arg, int arg_count,/* enlarge our value buffer by a suitable margin if needed */ if (upto + len > value_size) { value_size = (upto + len) +500 ; - value =realloc (value, value_size); -if (!value) { +void *save_ptr =realloc (value, value_size); + +if (!save_ptr) { +free (value);fprintf (stderr,"Out of mmory: cannot alloc " "%d bytes\n" , value_size);return -1 ; } + value = save_ptr; } ptr = value + upto;
Signature · 1 line
2.7.1.1.g3617aa0
Quoted 2 lines · Maxim Zhukov
[PATCH 1/2] scripts: genksyms: fix resource leak [PATCH 2/2] scripts: dtc: fix memory leak after realloc
scripts/dtc is just an import of upstream dtc[1]. So your patches need to be against that and sent to [email protected]. Once they are in, I can do a new import.
Rob
[1] git://git.kernel.org/pub/scm/utils/dtc/dtc.git
Quoted 8 lines · Rob Herring
Quoted 2 lines · Maxim Zhukov
[PATCH 1/2] scripts: genksyms: fix resource leak [PATCH 2/2] scripts: dtc: fix memory leak after realloc
scripts/dtcis just an import of upstream dtc[1]. So your patches need to be against that and sent to [email protected]. Once they are in, I can do a new import.
Sorry, that's only for patch 2.
Rob
Quoted 4 lines
Rob
[1]
git://git.kernel.org/pub/scm/utils/dtc/dtc.git