#include "power.h"
 #include "media.h"
 
+static void audioformat_free(struct audioformat *fp)
+{
+       list_del(&fp->list); /* unlink for avoiding double-free */
+       kfree(fp->rate_table);
+       kfree(fp->chmap);
+       kfree(fp);
+}
+
 /*
  * free a substream
  */
 
        if (!subs->num_formats)
                return; /* not initialized */
-       list_for_each_entry_safe(fp, n, &subs->fmt_list, list) {
-               kfree(fp->rate_table);
-               kfree(fp->chmap);
-               kfree(fp);
-       }
+       list_for_each_entry_safe(fp, n, &subs->fmt_list, list)
+               audioformat_free(fp);
        kfree(subs->rate_list.list);
        kfree(subs->str_pd);
        snd_media_stream_delete(subs);
        /* ok, let's parse further... */
        if (snd_usb_parse_audio_format(chip, fp, format,
                                        fmt, stream) < 0) {
-               kfree(fp->rate_table);
-               kfree(fp);
+               audioformat_free(fp);
                return NULL;
        }
 
 
                pd = kzalloc(sizeof(*pd), GFP_KERNEL);
                if (!pd) {
-                       kfree(fp->chmap);
-                       kfree(fp->rate_table);
-                       kfree(fp);
+                       audioformat_free(fp);
                        return NULL;
                }
                pd->pd_id = (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
                /* ok, let's parse further... */
                if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) {
                        kfree(pd);
-                       kfree(fp->chmap);
-                       kfree(fp->rate_table);
-                       kfree(fp);
+                       audioformat_free(fp);
                        return NULL;
                }
        }
                        err = snd_usb_add_audio_stream(chip, stream, fp);
 
                if (err < 0) {
-                       list_del(&fp->list); /* unlink for avoiding double-free */
+                       audioformat_free(fp);
                        kfree(pd);
-                       kfree(fp->rate_table);
-                       kfree(fp->chmap);
-                       kfree(fp);
                        return err;
                }
                /* try to set the interface... */