Projects STRLCPY criu Commits b6d397e4
🤬
  • kdat: lazy-thp: split error paths cleanups to two cases

    When an error occurs we need to close a file descriptor and unmap a region.
    Use a separate label for each cleanup.
    
    Fix CID 182644 (#1-2 of 2): Use after close (USE_AFTER_FREE)8. pass_closed_arg:
    Passing closed handle f.fd as an argument to bclose
    
    Signed-off-by: Mike Rapoport <[email protected]>
    Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading...
  • Mike Rapoport committed with Andrei Vagin 7 years ago
    b6d397e4
    1 parent f7724aa5
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    criu/kerndat.c
    skipped 783 lines
    784 784   f.fd = open("/proc/self/smaps", O_RDONLY);
    785 785   if (f.fd < 0) {
    786 786   pr_perror("Can't open /proc/self/smaps");
    787  - goto out;
     787 + goto out_unmap;
    788 788   }
    789 789   if (bfdopenr(&f))
    790  - goto out;
     790 + goto out_unmap;
    791 791   
    792 792   while ((str = breadline(&f)) != NULL) {
    793 793   if (IS_ERR(str))
    794  - goto out;
     794 + goto out_close;
    795 795   
    796 796   if (is_vma_range_fmt(str)) {
    797 797   unsigned long vma_addr;
    798 798   
    799 799   if (sscanf(str, "%lx-", &vma_addr) != 1) {
    800 800   pr_err("Can't parse: %s\n", str);
    801  - goto out;
     801 + goto out_close;
    802 802   }
    803 803   
    804 804   if (vma_addr == (unsigned long)addr)
    skipped 13 lines
    818 818   
    819 819   ret = 0;
    820 820   
    821  -out:
     821 +out_close:
    822 822   bclose(&f);
     823 +out_unmap:
    823 824   munmap(addr, PAGE_SIZE);
    824 825   
    825 826   return ret;
    skipped 60 lines
Please wait...
Page is in error, reload to recover