Changeset de16f89 in mainline for uspace/drv/audio/hdaudio/hdaudio.c


Ignore:
Timestamp:
2014-09-05T08:52:51Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
089901e
Parents:
3fec817
Message:

Add cleanup code to error paths.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/hdaudio/hdaudio.c

    r3fec817 rde16f89  
    150150static int hda_dev_add(ddf_dev_t *dev)
    151151{
    152         ddf_fun_t *fun_pcm;
     152        ddf_fun_t *fun_pcm = NULL;
    153153        hda_t *hda = NULL;
    154154        hw_res_list_parsed_t res;
    155155        irq_code_t irq_code;
    156         irq_cmd_t *cmds;
     156        irq_cmd_t *cmds = NULL;
    157157        size_t ncmds_base;
    158158        size_t ncmds_sdesc;
    159159        size_t ncmds;
    160160        int i;
    161         void *regs;
     161        void *regs = NULL;
    162162        int rc;
    163163
    164164        ddf_msg(LVL_NOTE, "hda_dev_add()");
     165        hw_res_list_parsed_init(&res);
    165166
    166167        hda = ddf_dev_data_alloc(dev, sizeof(hda_t));
     
    181182
    182183        ddf_msg(LVL_NOTE, "get HW res list");
    183         hw_res_list_parsed_init(&res);
    184184        rc = hw_res_get_list_parsed(hda->parent_sess, &res, 0);
    185185        if (rc != EOK) {
     
    270270        }
    271271
     272        free(cmds);
     273        cmds = NULL;
     274
    272275        if (hda_ctl_init(hda) == NULL) {
    273276                rc = EIO;
     
    295298
    296299        ddf_fun_add_to_category(fun_pcm, "audio-pcm");
     300
     301        hw_res_list_parsed_clean(&res);
    297302        return EOK;
    298303error:
     304        if (fun_pcm != NULL)
     305                ddf_fun_destroy(fun_pcm);
    299306        if (hda != NULL) {
    300307                if (hda->ctl != NULL)
    301308                        hda_ctl_fini(hda->ctl);
    302309        }
     310        free(cmds);
     311        // pio_disable(regs);
     312        hw_res_list_parsed_clean(&res);
    303313
    304314        ddf_msg(LVL_NOTE, "Failing hda_dev_add() -> %d", rc);
     
    323333        }
    324334
     335        hda_ctl_fini(hda->ctl);
     336        // pio_disable(regs);
    325337        return EOK;
    326338}
Note: See TracChangeset for help on using the changeset viewer.