From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F712C433DF for ; Thu, 30 Jul 2020 16:02:28 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E73F22CA0 for ; Thu, 30 Jul 2020 16:02:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E73F22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2EF8786447; Thu, 30 Jul 2020 16:02:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TXbsB-m9PGeS; Thu, 30 Jul 2020 16:02:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id AF33E86CAE; Thu, 30 Jul 2020 16:02:27 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id D44A61BF3F6 for ; Thu, 30 Jul 2020 16:02:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CB89C86CAE for ; Thu, 30 Jul 2020 16:02:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0ftcgoDB4ez7 for ; Thu, 30 Jul 2020 16:02:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by fraxinus.osuosl.org (Postfix) with ESMTPS id BA8F386447 for ; Thu, 30 Jul 2020 16:02:24 +0000 (UTC) Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k1B0g-0000qJ-T6; Thu, 30 Jul 2020 16:02:22 +0000 To: Johan Hovold , Alex Elder , "Greg Kroah-Hartman , Mark Greer , greybus-dev@lists.linaro.org, "devel@driverdev.osuosl.org" From: Colin Ian King Autocrypt: addr=colin.king@canonical.com; prefer-encrypt=mutual; keydata= mQINBE6TJCgBEACo6nMNvy06zNKj5tiwDsXXS+LhT+LwtEsy9EnraKYXAf2xwazcICSjX06e fanlyhB0figzQO0n/tP7BcfMVNG7n1+DC71mSyRK1ZERcG1523ajvdZOxbBCTvTitYOy3bjs +LXKqeVMhK3mRvdTjjmVpWnWqJ1LL+Hn12ysDVVfkbtuIm2NoaSEC8Ae8LSSyCMecd22d9Pn LR4UeFgrWEkQsqROq6ZDJT9pBLGe1ZS0pVGhkRyBP9GP65oPev39SmfAx9R92SYJygCy0pPv BMWKvEZS/7bpetPNx6l2xu9UvwoeEbpzUvH26PHO3DDAv0ynJugPCoxlGPVf3zcfGQxy3oty dNTWkP6Wh3Q85m+AlifgKZudjZLrO6c+fAw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FzBwgQqBnkA7dhBsQm3V0R8JTtMAqJGmyOcL+JCJAca 3Yi81yLyhmYzcRASLvJmoPTsDp2kZOdGr05Dt8aGPRJL33Jm+igfd8EgcDYtG6+F8MCBOult TTAu+QAijRPZv1KhEJXwUSke9HZvzo1tNTlY3h6plBsBufELu0mnqQvHZmfa5Ay99dF+dL1H WNp62+mTeHsX6v9EACH4S+Cw9Q1qJElFEu9/1vFNBmGY2vDv14gU2xEiS2eIvKiYl/b5Y85Q QLOHWV8up73KK5Qq/6bm4BqVd1rKGI9un8kezUQNGBKre2KKs6wquH8oynDP/baoYxEGMXBg GF/qjOC6OY+U7kNUW3N/A7J3M2VdOTLu3hVTzJMZdlMmmsg74azvZDV75dUigqXcwjE= Subject: issue with uninitialized value used in a comparison in gbcodec_mixer_dapm_ctl_put Message-ID: <7da6363c-9423-2b9f-029a-395cc8a932d7@canonical.com> Date: Thu, 30 Jul 2020 17:02:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" Hi, Static analysis with Coverity has detected an uninitialized value being used in a comparison. The error was detected on a recent change to drivers/staging/greybus/audio_topology.c however the issue actually dates back to the original commit: commit 6339d2322c47f4b8ebabf9daf0130328ed72648b Author: Vaibhav Agarwal Date: Wed Jan 13 14:07:51 2016 -0700 greybus: audio: Add topology parser for GB codec The analysis is as follows: 425 static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, 426 struct snd_ctl_elem_value *ucontrol) 427 { 428 int ret, wi, max, connect; 429 unsigned int mask, val; 430 struct gb_audio_ctl_elem_info *info; 431 struct gbaudio_ctl_pvt *data; 1. var_decl: Declaring variable gbvalue without initializer. 432 struct gb_audio_ctl_elem_value gbvalue; 433 struct gbaudio_module_info *module; 434 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); 435 struct snd_soc_dapm_widget *widget = wlist->widgets[0]; 436 struct device *codec_dev = widget->dapm->dev; 437 struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev); 438 struct gb_bundle *bundle; 439 2. Condition 0 /* __builtin_types_compatible_p() */, taking false branch. 3. Condition 1 /* __builtin_types_compatible_p() */, taking true branch. 4. Falling through to end of if statement. 5. Condition !!branch, taking false branch. 6. Condition ({...; !!branch;}), taking false branch. 440 dev_dbg(codec_dev, "Entered %s:%s\n", __func__, kcontrol->id.name); 441 module = find_gb_module(gb, kcontrol->id.name); 7. Condition !module, taking false branch. 442 if (!module) 443 return -EINVAL; 444 445 data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; 446 info = (struct gb_audio_ctl_elem_info *)data->info; 8. Condition 0 /* !!(!__builtin_types_compatible_p() && !__builtin_types_compatible_p()) */, taking false branch. 447 bundle = to_gb_bundle(module->dev); 448 9. Condition data->vcount == 2, taking true branch. 449 if (data->vcount == 2) 450 dev_warn(widget->dapm->dev, 451 "GB: Control '%s' is stereo, which is not supported\n", 452 kcontrol->id.name); 453 454 max = le32_to_cpu(info->value.integer.max); 455 mask = (1 << fls(max)) - 1; 456 val = ucontrol->value.integer.value[0] & mask; 10. Condition !!val, taking true branch. 457 connect = !!val; 458 459 /* update ucontrol */ Uninitialized scalar variable (UNINIT) 11. uninit_use: Using uninitialized value gbvalue.value.integer_value[0]. 460 if (gbvalue.value.integer_value[0] != val) { The gbvalue.value.integer_value[0] read is bogus since gbvalue was declared on the stack but was not initialized. There seems to be no where that sets this data. I'm assuming most of the time that the comparison works because the garbage value is different from val and so the code in the if stanza is executed. Anyhow, I'm unsure what the original intent of the code was, so I've not attempted to fix this. Colin _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel