Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp46642pxk; Tue, 15 Sep 2020 17:21:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZvcSRUfZFPyMiAR/MHKC8Cn01eqRjQCW5IH/Tr3QoR3LLQjj0x7sJd9IDfAvZGBNDNEdY X-Received: by 2002:a05:6402:1558:: with SMTP id p24mr24358668edx.194.1600215691505; Tue, 15 Sep 2020 17:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600215691; cv=none; d=google.com; s=arc-20160816; b=dciXsOl2GvFIGr1D3tX9Gfk9WXjU/oOEy0Z178NVYDcE4bUfU+W41Xg4PZK/Szb8Sw 3UPum67c91enjfBZegXYigoe2GIihxmUzW624S34cdpFnMNBF2mCjTvcO8dyODUi++7d w/gHxO9+rxB8uHGd85pryxDvWSFYxj5iDuVtGZIVucmiMlkbNSBPgah34iTyhMn+Wi0R voynX2JKm9X8BhSwU8fPqMqOInE4gz42mKO69eO9/2Z6i4XfZGzzL1y95yNlraTkcZUE II4nc76/YlrQUjsBqwedllKD6yG+bnnbFCpHnsA0yubqLw9Mp/n84iXrkXHSl6+IrGYY HN9w== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=K/fgAl1NnAi6X033I78B0I55gzJ5D1xw9p5orXjsKwk=; b=D54J5RcbS/VDO4Gn1h/d0uwKBLyWZ/s72f8oGmQJ1yzVhmrtzG9Vkphmqi0lvFImUj ukEcKV0l7QRQw/RCfZRmN7iv7p0VNc03Fq5pnJ/1rZi/PJ4qZXCVBFeIpIjh0Xc8nMsv B/uQanbRyYb54hIgBGJE0H54/BIDASHwTFiGAhqCyAeYg2BLJZBcsPD16TrmBl0THBcQ qTEQF04blpwhc3h2I6DiPkst3q+zEgOVKijeARvZ21xT7DyjxAG8WDpO+mcefkOpI270 LWLPc350a8L4BKQcpepcJ6PkKkizCIP+aN+0WMv7lC/6kAp/f+/6Nm8maAs/CqSf+BKH 5wGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vwl9ZK66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mc20si10161948ejb.571.2020.09.15.17.21.09; Tue, 15 Sep 2020 17:21:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vwl9ZK66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727179AbgIPATW (ORCPT + 99 others); Tue, 15 Sep 2020 20:19:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:38262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgIOOWr (ORCPT ); Tue, 15 Sep 2020 10:22:47 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5C5C22284; Tue, 15 Sep 2020 14:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179466; bh=3DeDof8zH8ebgLROJLAJWdreYRB88ogNi4I2Oja4Bdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vwl9ZK66VpLSREXQLHarELiSg07ZCzWKAMFcP5+F9andQVJgzMkFuvmSQAzq5g6Mm AaaNQN/tPpk8INaG/c79fkvg0x9i3y2HgydDG8HidY+amH67aH22AaYMCRsCMV5FIA hgHyTWeqmfPvr8zztO2eXa7S4bnFrXVTYrEM7uUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Vaibhav Agarwal Subject: [PATCH 4.19 71/78] staging: greybus: audio: fix uninitialized value issue Date: Tue, 15 Sep 2020 16:13:36 +0200 Message-Id: <20200915140637.141656938@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 From: Vaibhav Agarwal commit 1dffeb8b8b4c261c45416d53c75ea51e6ece1770 upstream. The current implementation for gbcodec_mixer_dapm_ctl_put() uses uninitialized gbvalue for comparison with updated value. This was found using static analysis with coverity. Uninitialized scalar variable (UNINIT) 11. uninit_use: Using uninitialized value gbvalue.value.integer_value[0]. 460 if (gbvalue.value.integer_value[0] != val) { This patch fixes the issue with fetching the gbvalue before using it for comparision. Fixes: 6339d2322c47 ("greybus: audio: Add topology parser for GB codec") Reported-by: Colin Ian King Signed-off-by: Vaibhav Agarwal Cc: stable Link: https://lore.kernel.org/r/bc4f29eb502ccf93cd2ffd98db0e319fa7d0f247.1597408126.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_topology.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c @@ -460,6 +460,15 @@ static int gbcodec_mixer_dapm_ctl_put(st val = ucontrol->value.integer.value[0] & mask; connect = !!val; + ret = gb_pm_runtime_get_sync(bundle); + if (ret) + return ret; + + ret = gb_audio_gb_get_control(module->mgmt_connection, data->ctl_id, + GB_AUDIO_INVALID_INDEX, &gbvalue); + if (ret) + goto exit; + /* update ucontrol */ if (gbvalue.value.integer_value[0] != val) { for (wi = 0; wi < wlist->num_widgets; wi++) { @@ -473,25 +482,17 @@ static int gbcodec_mixer_dapm_ctl_put(st gbvalue.value.integer_value[0] = cpu_to_le32(ucontrol->value.integer.value[0]); - ret = gb_pm_runtime_get_sync(bundle); - if (ret) - return ret; - ret = gb_audio_gb_set_control(module->mgmt_connection, data->ctl_id, GB_AUDIO_INVALID_INDEX, &gbvalue); - - gb_pm_runtime_put_autosuspend(bundle); - - if (ret) { - dev_err_ratelimited(codec->dev, - "%d:Error in %s for %s\n", ret, - __func__, kcontrol->id.name); - return ret; - } } - return 0; +exit: + gb_pm_runtime_put_autosuspend(bundle); + if (ret) + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, + __func__, kcontrol->id.name); + return ret; } #define SOC_DAPM_MIXER_GB(xname, kcount, data) \