]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: hda/generic: Use auto cleanup for temporary buffers
authorTakashi Iwai <tiwai@suse.de>
Wed, 27 Aug 2025 07:29:01 +0000 (09:29 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 09:52:15 +0000 (11:52 +0200)
The release of temporary kmalloced buffers can be nicely handled via
the standard __free(kfree).

Only code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250827072916.31933-22-tiwai@suse.de
sound/hda/codecs/generic.c

index e1324f9671dd49a553b1a903805f50c53cd1294c..7bcf9aef8275f9c8232bd9620006fd0bdbbcfb24 100644 (file)
@@ -1984,7 +1984,7 @@ static int parse_output_paths(struct hda_codec *codec)
 {
        struct hda_gen_spec *spec = codec->spec;
        struct auto_pin_cfg *cfg = &spec->autocfg;
-       struct auto_pin_cfg *best_cfg;
+       struct auto_pin_cfg *best_cfg __free(kfree) = NULL;
        unsigned int val;
        int best_badness = INT_MAX;
        int badness;
@@ -2000,10 +2000,8 @@ static int parse_output_paths(struct hda_codec *codec)
        for (;;) {
                badness = fill_and_eval_dacs(codec, fill_hardwired,
                                             fill_mio_first);
-               if (badness < 0) {
-                       kfree(best_cfg);
+               if (badness < 0)
                        return badness;
-               }
                debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
                              cfg->line_out_type, fill_hardwired, fill_mio_first,
                              badness);
@@ -2096,7 +2094,6 @@ static int parse_output_paths(struct hda_codec *codec)
        if (spec->indep_hp && !indep_hp_possible(codec))
                spec->indep_hp = 0;
 
-       kfree(best_cfg);
        return 0;
 }