From: Takashi Iwai Date: Wed, 27 Aug 2025 07:29:01 +0000 (+0200) Subject: ALSA: hda/generic: Use auto cleanup for temporary buffers X-Git-Tag: v6.18-rc1~135^2~206 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee0b0f5d32fe33562228096ed8edd4999be35092;p=thirdparty%2Flinux.git ALSA: hda/generic: Use auto cleanup for temporary buffers 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 Link: https://patch.msgid.link/20250827072916.31933-22-tiwai@suse.de --- diff --git a/sound/hda/codecs/generic.c b/sound/hda/codecs/generic.c index e1324f9671dd4..7bcf9aef8275f 100644 --- a/sound/hda/codecs/generic.c +++ b/sound/hda/codecs/generic.c @@ -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; }