Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4059670imm; Mon, 11 Jun 2018 06:25:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0q0qOZ2k1m7rzxeDRvfMh7tWCftoxWLKusoVNo2IqGDJ4Nk/DBppzCfIRfwcGjz2lTRLW X-Received: by 2002:aa7:80cf:: with SMTP id a15-v6mr17497084pfn.19.1528723525823; Mon, 11 Jun 2018 06:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528723525; cv=none; d=google.com; s=arc-20160816; b=SLDm1lZfsNiaKd3gqAkp8tJBijwlYrQyJmFimSZO4Pf6snlKPvWUVk3wU2rorTdlX3 hguwH2Oe+863G41FVyXRRrxD33U6pMOYd/4BXsf4M/vrqBZibJTyMmnj3iMhEa28HkvW ntpRJMKZoQfxCForlJzaSJ3nSv1mf17X0oLbXPdgDd36joXLDYrLY9vD7mGj2CTxQhl/ DtEo20bpFY4SW7zs5ZCqUH03FjumZSqkYurrmKNjl0o8bYDNm2eMZ7HofYmOmyHngeMB EbfZk/xB+USwyhE+sXrqNkcyZ5UgaEAM7IumcsJ8Vac4Lh9Ff+koDGKNgGrIWHPBqW9D 0uXw== 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 :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:arc-authentication-results; bh=/K1MHNhT5FVauUuOQw0mFIzuUf6/kd+LD+yZAvvMf1w=; b=eD0eU0gwPVcY8ekPtrUl1bYwxfh5fkozFZIEup6QeaOkXHkcW/3Fb5WFImTHgDkm4j gjWSkOZvNlwSmBd8cqouPmFeMq8xVJwTtpzXzWQQqrkCfq0xrcE1LfPn/LSJLd6cTN4D BVBO9yyPCbbBf8KXV1hSI26Vead/sA8d4rK5hDtwI3BTxrkL4R88ljbDKsosh5PhdGwu xwDGL8kwRylsPcvuIYq4TdqxIMU+/WO/Pf3fJUZXs31LmwIB+cQQOXw2bgYFFgoqxga9 9/nVjT698oKxA/1lezwz114yxLY6ogR4rx+u5sdUEn2EEzFOvUHRSk4+x813NhAk9xWD +4hQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si34418118pll.275.2018.06.11.06.25.11; Mon, 11 Jun 2018 06:25:25 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933037AbeFKNYp (ORCPT + 99 others); Mon, 11 Jun 2018 09:24:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:53203 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932607AbeFKNYo (ORCPT ); Mon, 11 Jun 2018 09:24:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B9B81AC44; Mon, 11 Jun 2018 13:24:42 +0000 (UTC) Date: Mon, 11 Jun 2018 15:24:42 +0200 Message-ID: From: Takashi Iwai To: "Andy Shevchenko" Cc: =?UTF-8?B?IsOJbWVyaWMgTUFTQ0hJTk8i?= , , , "BhumikaGoyal" , "Jaroslav Kysela" , Subject: Re: [PATCH] ALSA: fm801: add error handling for snd_ctl_add In-Reply-To: <520e80a8b8de0f532e8dd3ee15af9efbc748dd9a.camel@linux.intel.com> References: <1528704248-33818-1-git-send-email-jiazhouyang09@gmail.com> <520e80a8b8de0f532e8dd3ee15af9efbc748dd9a.camel@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 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, 11 Jun 2018 10:49:56 +0200, Andy Shevchenko wrote: > > 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). I applied now as this change is pretty safe. thanks, Takashi > > > 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 >