Changeset 64eba57 in mainline


Ignore:
Timestamp:
2024-11-15T17:39:24Z (6 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
dfa2313
Parents:
b235c67
Message:

hrctl: fix memory leaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hrctl/hrctl.c

    rb235c67 r64eba57  
    252252                case 'h':
    253253                        usage();
     254                        free(cfg);
    254255                        return 0;
    255256                case 's':
     257                        free(cfg);
    256258                        rc = hr_print_status();
    257259                        if (rc != EOK)
     
    263265                        if (rc != EOK) {
    264266                                printf("hrctl: failed to load config\n");
     267                                free(cfg);
    265268                                return 1;
    266269                        }
     
    270273                        if (str_size(optarg) > sizeof(cfg->devname) - 1) {
    271274                                printf("hrctl: device name too long\n");
     275                                free(cfg);
    272276                                return 1;
    273277                        }
     
    279283                        if (rc != EOK) {
    280284                                printf("hrctl: failed to load config\n");
     285                                free(cfg);
    281286                                return 1;
    282287                        }
     
    286291                        if (str_size(optarg) > sizeof(cfg->devname) - 1) {
    287292                                printf("hrctl: device name too long\n");
     293                                free(cfg);
    288294                                return 1;
    289295                        }
     
    334340                                goto bad;
    335341                        rc = fill_config_devs(argc, argv, optind, cfg);
    336                         if (rc != EOK)
    337                                 return 1;
     342                        if (rc != EOK) {
     343                                free(cfg);
     344                                return 1;
     345                        }
    338346                        break;
    339347                }
     
    346354        if (create && cfg->level == HR_LVL_UNKNOWN) {
    347355                printf("hrctl: invalid level, exiting\n");
    348                 return 1;
     356                goto bad;
    349357        }
    350358
    351359        if (cfg->dev_no > HR_MAXDEVS) {
    352360                printf("hrctl: too many devices, exiting\n");
    353                 return 1;
     361                goto bad;
    354362        }
    355363
    356364        if (cfg->dev_no == 0) {
    357365                printf("hrctl: invalid number of devices, exiting\n");
    358                 return 1;
     366                goto bad;
    359367        }
    360368
Note: See TracChangeset for help on using the changeset viewer.