From patchwork Mon Jun 29 16:10:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 6689961 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 635C59F1C1 for ; Mon, 29 Jun 2015 16:10:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95551205E1 for ; Mon, 29 Jun 2015 16:10:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 71A99205DB for ; Mon, 29 Jun 2015 16:10:47 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 65ADE2654F6; Mon, 29 Jun 2015 18:10:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 710C9265467; Mon, 29 Jun 2015 18:10:40 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 947C1265487; Mon, 29 Jun 2015 18:10:39 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id A7429265342 for ; Mon, 29 Jun 2015 18:10:32 +0200 (CEST) Received: from 1.general.cking.us.vpn ([10.172.65.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1Z9bdb-0002lv-KP; Mon, 29 Jun 2015 16:10:28 +0000 From: Colin King To: Jaroslav Kysela , Takashi Iwai , Mark Brown , Jie Yang , alsa-devel@alsa-project.org Date: Mon, 29 Jun 2015 17:10:22 +0100 Message-Id: <1435594222-17690-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 Cc: linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ALSA: Fix uninintialized error return X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King Static analysis with cppcheck found the following error: [sound/core/init.c:118]: (error) Uninitialized variable: err ..this was introduced by commit 2471b6c80a70e80de69f5ff4c37187c3912e5874 ("ALSA: info: Register proc entries recursively, too") where the call to snd_info_card_register was removed and no longer setting the error return in err. When snd_info_create_card_entry fails to allocate a an entry, the error path exits with garbage in err. Fix is to return -ENOMEM if entry fails to be allocated. Author: Takashi Iwai Date: Mon May 18 09:20:24 2015 +0200 Fixes: 2471b6c80a ("ALSA: info: Register proc entries recursively, too") Signed-off-by: Colin Ian King --- sound/core/init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/core/init.c b/sound/core/init.c index 3e0ceba..20f37fb 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -109,13 +109,12 @@ static void snd_card_id_read(struct snd_info_entry *entry, static int init_info_for_card(struct snd_card *card) { - int err; struct snd_info_entry *entry; entry = snd_info_create_card_entry(card, "id", card->proc_root); if (!entry) { dev_dbg(card->dev, "unable to create card entry\n"); - return err; + return -ENOMEM; } entry->c.text.read = snd_card_id_read; card->proc_id = entry;