Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3762964imm; Mon, 11 Jun 2018 01:05:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFZoCooBGa1CmQG33Z1mFi/G+tqWZ1j9PamYT4rSy9pcgZ2KwozfAZxZmrsLq2//2P83iE X-Received: by 2002:a17:902:654c:: with SMTP id d12-v6mr17266165pln.8.1528704313044; Mon, 11 Jun 2018 01:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528704313; cv=none; d=google.com; s=arc-20160816; b=cgbNox3EpnHx4+1P+lHT5zRhhJAkSZRBvwPEUyAcsxjtzaF0TpNPfzbUYGNjAr7Awe Xa8GvI2RtloxVfF2+3/jWZQxHr99ohhR03+ghqjiVIW0WOQuxYRVnxMyCCjUorx61Lqy VvkyNyTqVvjSWfUtHRYZ+coa77nDigAtvJ0SGqgNnoekRVKzwYtjrvezJdd0S6ESSv1V m/buxyuzyAKb3OPAmyGjkPY2pch4y2wbgl03sbGSML0Iq8Xtr+5VJVWzZJJ8r21BT7df aLijueSgsCF+0hD1+boqQZfpiLFWsWa5OgjspzuYh3Fgx5jqUUZ+5Y09ImlFd1mTSFTq Euog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=6buNHpilJC47JmswQicQ5Bz16gdrS9D7/ZFV6sZ6FoI=; b=uDVwr/ItgYTJMvqBJtxKwXpj0tpm0bU4ooEqOOMhBqKOPE8NgbewZh8UoErCE4WuoR psyx2OGurR6bHwVCiBLyUiFyofcxJoH48nXgt6ozxTkZ+xPaxnLirCK9yqHTApiUJ14e mywsnqJm/vwqh23b1XzlEeIGecmnhKBYMzdT6FQtAuArGlolvOeSGqENxXomNpDu3hVO cA0B+156Z1eiagEgXPtDZFuhDK8w8l15Kbu8ubhCciUJzp3NcIVvxFEmG4Nw3VL4vRC/ fNh6fhZgoSuFUy+bfg7T260QkZTII8vHoUAF5zt4U674UVE44spS8zv5fZoTJDU15X6o WMmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WiYmd1JH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14-v6si24383520pgo.314.2018.06.11.01.04.58; Mon, 11 Jun 2018 01:05:13 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WiYmd1JH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754125AbeFKIEV (ORCPT + 99 others); Mon, 11 Jun 2018 04:04:21 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:40814 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754006AbeFKIET (ORCPT ); Mon, 11 Jun 2018 04:04:19 -0400 Received: by mail-pl0-f67.google.com with SMTP id t12-v6so11844819plo.7 for ; Mon, 11 Jun 2018 01:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6buNHpilJC47JmswQicQ5Bz16gdrS9D7/ZFV6sZ6FoI=; b=WiYmd1JH3AbUZ0oobJopkuGjN1unFG13K9cIEIyN8iCANGpzmw1icqc26rZkRyuV6o SMuS/Vk6B54klQV/U5Z5jB6axlEh2XtbRh0M6JGuAS+WH02XGFvyYSFLDOPoJUEPMMgz jcVq33pRCmAtwAFByX/Vzq9DrZnWwUlF00v39LVedhoNLicy57jiMsPJZl0RlWD4kEhc QiBgmErDlCQm2BTJTrHtJFyX/UxRNFlzk5naQ2yRoVLdyQ2f+aNdwoE8pciQplud9ILZ jFrr2T9hzuOPaNyUbdwndx6oEMkgyDh3ttlqjUNnSKmLaUpW83/TvAR02aKvfkxTYaD9 JCQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6buNHpilJC47JmswQicQ5Bz16gdrS9D7/ZFV6sZ6FoI=; b=sjtCSzelUPzYnEgValPFHjBh5u30qN9euh33qVNJ5lLC9BW8qjMX4yHaGacEtFoFcY fzMnnf/3Er07y5EX1uwEGI1w3sXk1mKtADVhgap/TqwR+TNmhhiDPRIO5FTUAM93pQhs TqcYdv03xDYxxS8Q234/fvwRGy4b96CbXRCs2yjMWrDMSefPj/4Hd4mRyep7+0qaGDg/ 1kbqrPHyuquetRm5TKz+vmA47Zz666iQXvq87BOOM6f/J0EzgppFD74/T5YdQbfmKzpj bf72EL+nqdZ3lJ7vbBWDSfLKCbUmQUuih29h/vMMmClEgju9DceNuIofmOBxwa3goIJ9 MP9A== X-Gm-Message-State: APt69E2xutDDJ1jlRmuM3bMRS+ImMOeV6UZMwRMr68r+f50vcDdliUcn b7Pny+ekWNvokzFKVJUjsNU= X-Received: by 2002:a17:902:6903:: with SMTP id j3-v6mr17253415plk.313.1528704258856; Mon, 11 Jun 2018 01:04:18 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id b84-v6sm83790897pfm.123.2018.06.11.01.04.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 01:04:18 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko , Bhumika Goyal , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: fm801: add error handling for snd_ctl_add Date: Mon, 11 Jun 2018 16:04:06 +0800 Message-Id: <1528704248-33818-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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_multi[i], chip)); + if (err < 0) + return err; + } } return 0; } -- 2.7.4