Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3298877pxk; Mon, 21 Sep 2020 10:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziyyPsz9NWazr4TUNMMY0WxRnqZA8CJO3lWMcqwZ0lBIP2GQ1XDJdNs5JBMysu68Xjzwb9 X-Received: by 2002:a1c:9a57:: with SMTP id c84mr330659wme.136.1600707701680; Mon, 21 Sep 2020 10:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707701; cv=none; d=google.com; s=arc-20160816; b=DyT7NNuQZRgGt4iPPdbv7DUxFXFqqSAExTeHgXUA5W02dPr+Su2pZgykT1xcdjXxBK 79XWu0CjIh7uny5EU1UYvQgAYGOKAtCw1z8K6dyUGsLhwphIOkjMFD1Qm7FAu5b7yg6g Q0o9kyHFA6HAfejk16L3vcT9dXhkGqMtCBjUDU5gAKQ+Inbm/79YD/bBKnw1KfGPgUGF RgrP7HjFdbXzYyDbuvCwpxHPP5Dx6pWx5IXWY5F6LW6WFC+a5uOdy9vL8AUjhHfA21Q0 gVj87CLFzEaEMf5/hYzZdIVW7SbOVE17Fb51xYigTKrxqvlDCWapdys6dFITEod0Iy8B GWmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A78U9FEhh8kCZ3Z9QX2DCCX6KYDYG1nSF8NXJp4xr90=; b=ClmrWch0ETvkgJZoa4Gvs/ub9fn51/WUBBKQwK7bdH2AvTHVIszn2O7IkaU8VeLU3N jpNui4z7P9VR6jyh71WjM+woqsKjxLEA3GVz6tz5mxU7ZYIsH2K9S7PiosrLmf4qB0V3 pgMp3i1sgpUfjVen0G1G+OpHdTsaMuWFp7JqenMferN0v6GD63DDjXR+uaOXexFVC0ZB B6MQLDq+RV1lUq+uYdO9RTdJJPt4gJ4zfUZah2VO9DIWCgQDT3YTM43cIQ1k1MCE6MQB XvisMBPwcdeCk4ojh+tS8wueUxyYoXmLbShlwMBW3vE1RoG75TUpBJqFfI8coV0szT7m K/jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b1lQNMtM; 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 cx6si8688448edb.437.2020.09.21.10.01.15; Mon, 21 Sep 2020 10:01:41 -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=b1lQNMtM; 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 S1730356AbgIURAS (ORCPT + 99 others); Mon, 21 Sep 2020 13:00:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728251AbgIUQkX (ORCPT ); Mon, 21 Sep 2020 12:40:23 -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 878B2239D2; Mon, 21 Sep 2020 16:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706423; bh=u9tGEo9VD5jeRRAWo/OqfreflTBAqOp7ub9K0jpKAWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1lQNMtMGGjM/gicTs1yHn86yZTKPL3GRIJDbvBthni2wjWKM0bxsazM3Mi+hgIgY piqO5LMryZVk/cCw2cP2mNropmpXSXsJQT4u7MhyIPI9oQvmYqy3JVSa1zpwUx+Guj 3E0jbGEAgSLeKHEu7ECfhGnKanvd0crf5b6XXPLs= 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.14 53/94] staging: greybus: audio: fix uninitialized value issue Date: Mon, 21 Sep 2020 18:27:40 +0200 Message-Id: <20200921162037.995226799@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 @@ -461,6 +461,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++) { @@ -474,25 +483,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) \