Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1158365imm; Wed, 1 Aug 2018 11:08:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfZGyKncPjlbd6PUEBZ1qgEHSTHNIBfgvfBFw/iGI/M4vpMirq83WYu304p9kHMLYdGTWBu X-Received: by 2002:a62:a6db:: with SMTP id r88-v6mr27963134pfl.60.1533146927173; Wed, 01 Aug 2018 11:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146927; cv=none; d=google.com; s=arc-20160816; b=B8q5wpCMcvKMg/tI+jy3fThdKUdQ5AitINPmA3jvswgaSaO6cNwZvAET8xezAm9FVB 8u7D53latpJ9PXqJqXLC4jJ/cKTDBWkcGVZSehxm00KcxRVrIRXAeSYDKcGtIEBc0YDT ep10k957BG5Pa77eTMYvz1Fl6BY5SByEByWSiSPxmLTsQ6Dy3GQqJqIo8dzvXlJd8vgo o6sNOy10+pAPQ7i0uTjPRj60urZVNLv178d3h2LWmATsEZP/EAevh9VPGqxCxzqQ3G7u oONZn7LfQQUmUslsGgkL0iVNDfX8W5f/VrX+ksJNdOjtTjVeh43Grsy6GWtu5ApCSCHI 05Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0yg/0vEVsLnMR7USjcui6RIarZNtQF7u/ifTE+g9eUE=; b=RhqL5td7BlEH4GstDEaH0m2l/k0W3l9LzheToMWCCbN2rlD9wQ3pDBgtAnFSsuPY7Z 1Z2wjMSbuVVkkIQZtQVyz7EVIzkvCezuyWgB1GuyUeEgUC66m5Zs+OGX4A+vcII8RZWL d7UJcd50qYSayKJKFOuH6G/0PFt7jX68VjlKnPZS3h0DDKT8qr+bM+4ZK/B2abtlQtR3 YXSS7/a7wPKm8JUonuE3f/GuUtYlUOqmbKtyWt3xMKV9x7vxDmufrY17XP34g12vSfiz YSXy75dVKshDJAN9RFq3oLD9I/DPMBSWa3NmWZL/24cFIGM039+bzPM8TbTOA8slT2ro rvYA== 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 t19-v6si17974308plj.334.2018.08.01.11.08.32; Wed, 01 Aug 2018 11:08:47 -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 S2387463AbeHATyF (ORCPT + 99 others); Wed, 1 Aug 2018 15:54:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50224 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405805AbeHATIh (ORCPT ); Wed, 1 Aug 2018 15:08:37 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 513AB13AA; Wed, 1 Aug 2018 17:15:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhouyang Jia , Andy Shevchenko , Takashi Iwai , Sasha Levin Subject: [PATCH 4.14 025/246] ALSA: fm801: add error handling for snd_ctl_add Date: Wed, 1 Aug 2018 18:48:55 +0200 Message-Id: <20180801165012.901786199@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhouyang Jia [ Upstream commit ef1ffbe7889e99f5b5cccb41c89e5c94f50f3218 ] 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. Signed-off-by: Zhouyang Jia Acked-by: Andy Shevchenko Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/pci/fm801.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 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_multi[i], chip)); + if (err < 0) + return err; + } } return 0; }