Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3798982imm; Mon, 11 Jun 2018 01:50:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRzifPibJ12Rl2kfgnp3oxL+bkOxbMCo3CYRG2siOwW36qgWR0rkzAUYM8anWQywQ0rIxu X-Received: by 2002:a17:902:d711:: with SMTP id w17-v6mr17250998ply.200.1528707039193; Mon, 11 Jun 2018 01:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528707039; cv=none; d=google.com; s=arc-20160816; b=HVokrlpPeEMWhi6PCIednOO3fBWMfwFHIKlNSD/6RU3IqE6bfkV4XH6iDhVe0gHlo7 wPdO3ERgs9u+1jbVwt8QdqaG5gx5BmZajVWSsOdH+CPCjxZdNdEy3HY9hxtRhmqcFwDt 70Ciyi6Hc7TyiAWDygKyVRG4Q+lFNxciZOu5ZDs0pbGFTnrrxSE1s9353MCFOpkcim/f 7rUrkrl3gI+GZX5/67r3CscDvGqUe52B8g0SGRkx+WYAF1LoHc0XjEkjnjQnvc2XJMI9 jhCVD4GkXCGss9r9IbvpAv3YhEKLbChuCYUrMOEzm+R9+EpkA//akSvJC35ELy+6a5rg urmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=jLodNGAsyKo0IrtBCZ94tW+OXS9+YinrKQvFleNjefw=; b=h7HXLNiE/lGJO8eaeb4Aqx6mBtGCou/ozlMK1lz+t49vReCN5ij+PGJnIjq0Y1MZ53 KvnJyLlKqKC7ATaOZur0RtLL3rHvVLCdi2gSdRkMQLL9CTJXe/r+usAx9hrVCGWchq2h FXGW/5roG6r35xx6ycIMZc+Pt5MYO3iS0C15WdVxlUmsZeZOFCido8FB/R0ms7IgY5H9 tqhGuYK2VwRr23PfdKlFTfNIL+LoqtPmuTt7B6DQJp0RuOLltc89Hy9XdJJrdkJjNz43 bWg+fCzs+gZ8E8exhMRLHsHzo4I6GVhQRLdvGygMGtWz9Qw1bZVY4b3BrH9qOVO9TS7+ ziBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si577541plp.506.2018.06.11.01.50.24; Mon, 11 Jun 2018 01:50:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754182AbeFKIuA (ORCPT + 99 others); Mon, 11 Jun 2018 04:50:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:46184 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754024AbeFKIt7 (ORCPT ); Mon, 11 Jun 2018 04:49:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2018 01:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,501,1520924400"; d="scan'208";a="236386113" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga006.fm.intel.com with ESMTP; 11 Jun 2018 01:49:56 -0700 Message-ID: <520e80a8b8de0f532e8dd3ee15af9efbc748dd9a.camel@linux.intel.com> Subject: Re: [PATCH] ALSA: fm801: add error handling for snd_ctl_add From: Andy Shevchenko To: jiazhouyang09@gmail.com, =?ISO-8859-1?Q?=C9meric?= MASCHINO Cc: Jaroslav Kysela , Takashi Iwai , Bhumika Goyal , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Date: Mon, 11 Jun 2018 11:49:56 +0300 In-Reply-To: <1528704248-33818-1-git-send-email-jiazhouyang09@gmail.com> References: <1528704248-33818-1-git-send-email-jiazhouyang09@gmail.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-06-11 at 16:04 +0800, jiazhouyang09@gmail.com wrote: > When snd_ctl_add fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling snd_ctl_add. > Acked-by: Andy Shevchenko Though I can't test this (I have FM-only card). Last person who would able to test was Émeric (Cc'ed). > Signed-off-by: Zhouyang Jia > --- > sound/pci/fm801.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c > index 73a67bc..e3fb9c6 100644 > --- a/sound/pci/fm801.c > +++ b/sound/pci/fm801.c > @@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 *chip) > if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, > &chip->ac97_sec)) < 0) > return err; > } > - for (i = 0; i < FM801_CONTROLS; i++) > - snd_ctl_add(chip->card, > snd_ctl_new1(&snd_fm801_controls[i], chip)); > + for (i = 0; i < FM801_CONTROLS; i++) { > + err = snd_ctl_add(chip->card, > + snd_ctl_new1(&snd_fm801_controls[i], chip)); > + if (err < 0) > + return err; > + } > if (chip->multichannel) { > - for (i = 0; i < FM801_CONTROLS_MULTI; i++) > - snd_ctl_add(chip->card, > snd_ctl_new1(&snd_fm801_controls_multi[i], chip)); > + for (i = 0; i < FM801_CONTROLS_MULTI; i++) { > + err = snd_ctl_add(chip->card, > + snd_ctl_new1(&snd_fm801_controls_mult > i[i], chip)); > + if (err < 0) > + return err; > + } > } > return 0; > } -- Andy Shevchenko Intel Finland Oy