From patchwork Sun Feb 27 16:43:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12762024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F612C433EF for ; Sun, 27 Feb 2022 16:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qPBXnfG0L5UKXfbDpjRkQv+dk/0eE24hQu0AS4FvY4A=; b=PnwGI5/+9emSrZ 3MX9zxLhmnHS/4bKH/1/J2fwBMQZzL2AeGQumCOWYfCrFVE4cewkE50yGIO+8iIKDtsfEIh/IgJ62 CXq3/bR4xsC8VdMolUIy26vvqrVlqkQARzlL4GwITJ84wlgyrcwDru+Jm5GAOfJltmwIUTVAo4VrN NVP3shK8pan0tRDjZOjdUJH+ynje0EJQt58+lE/ZVrcWZjr0Fb0haMxFfAkDG9XqNXrjiJAytxDaW g2qefESPgrFPiHZ2wv2pfqCo/fxgZJ57JJEjieZM89Xt0tz3z/C/etffWW1fFM9xO+bSc/7SgDSBC dgTPUc9VADDD4uelDEwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOMhS-009o6a-92; Sun, 27 Feb 2022 16:47:12 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOMeW-009mug-7C for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 16:44:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645980245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V5Y+mhXtEe4aHWk4DE77nNDoAlUo3znM4yBU3KLbx5o=; b=PtoP22aLZkHm+9erZ0TpBKv6ojexO/LGxEzAEPDnayrtV9fLK7417UQwBe4oLqnCIQxr/B SRIZs1xTNDinaSCc5+WBTXLcgRizrccfItrPE49vqMEWLFuu6FwaDl0nT9H7dy+TFf8jzs Y0mrAAAai0dJ+wdBDfov+L1qG3NxVVE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-c_8Xrvt8OLGRze7_5-6LJw-1; Sun, 27 Feb 2022 11:44:03 -0500 X-MC-Unique: c_8Xrvt8OLGRze7_5-6LJw-1 Received: by mail-qk1-f197.google.com with SMTP id c19-20020a05620a0cf300b005f17891c015so9474144qkj.18 for ; Sun, 27 Feb 2022 08:44:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V5Y+mhXtEe4aHWk4DE77nNDoAlUo3znM4yBU3KLbx5o=; b=XT030+LotTTFBKLEGOEggaMt1Z92y7DEKGji2LoEr/b94SZDO6QKwUSKnRrQyNL6yX JLB4rbJHGC9Y1jrdkDW1mZWbIIQKdclB4l5dZWLotwB+RwvBpaOjMKsIvJmMwyTW6wS/ XG/MWboyiMJvDR4uKQuI5GqJU5Xiqc8lTqkFfs148Xvy0Ojz7GQAGaHs5aKYv4qw4iUi ndRNqyU8IDTL2IB29TNlaZeZCQq3IBccSy1eNFQiW0m0T6bBlIaoOtqHLgTH7GL39eR4 jzjKOKAtQZq3XtonSa9YSTO8rlPiw3RtfBxPSTJGgGENARylImCwF7dsWH7lk49SPA1a erpA== X-Gm-Message-State: AOAM53390iemhRPxrMNdHpcoTvOs+uO5bNBtjnTAzIWurjb2VexoqjjZ Xb94rzaW7vdanUKRxNy3aat+4uytN/JRs/DlexNI1vhTzPAe+3zm2JFxer1SGGZCEN+CB7+/2Zk s1qDNQvX1Ykv5kXFqCmwnWyNgqBWBM16S7eM= X-Received: by 2002:a05:620a:1fc:b0:60d:d438:d628 with SMTP id x28-20020a05620a01fc00b0060dd438d628mr9489740qkn.388.1645980242783; Sun, 27 Feb 2022 08:44:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmEEmzM5eDcwZIwdUdPIYKMl5r3tEeMsKZSwUZGmeUMBHmHQtSkJ2w3iQrxB7UtVNBvR5apQ== X-Received: by 2002:a05:620a:1fc:b0:60d:d438:d628 with SMTP id x28-20020a05620a01fc00b0060dd438d628mr9489721qkn.388.1645980242555; Sun, 27 Feb 2022 08:44:02 -0800 (PST) Received: from localhost.localdomain.com (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id w140-20020a376292000000b00648e88c1f05sm4010675qkb.67.2022.02.27.08.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 08:44:02 -0800 (PST) From: trix@redhat.com To: jic23@kernel.org, lars@metafoo.de, matthias.bgg@gmail.com, nathan@kernel.org, ndesaulniers@google.com, linus.walleij@linaro.org, ardeleanalex@gmail.com Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Tom Rix Subject: [PATCH] iio: adc: mt6360: strengthen return check of mt6360_adc_read_channel Date: Sun, 27 Feb 2022 08:43:57 -0800 Message-Id: <20220227164357.84742-1-trix@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_084408_507700_E393A8F2 X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix Clang static analysis reports this issue mt6360-adc.c:277:20: warning: Assigned value is garbage or undefined data.values[i++] = val; ^ ~~~ val is set by a successful call to m6360_adc_read_channel(). A negative return is checked but within m6360_adc_read_channel, a non zero check is done. Strengthen the check to non zero. Signed-off-by: Tom Rix --- drivers/iio/adc/mt6360-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c index 07c0e67683910..9fb6dc305a392 100644 --- a/drivers/iio/adc/mt6360-adc.c +++ b/drivers/iio/adc/mt6360-adc.c @@ -269,7 +269,7 @@ static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p) memset(&data, 0, sizeof(data)); for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { ret = mt6360_adc_read_channel(mad, bit, &val); - if (ret < 0) { + if (ret) { dev_warn(&indio_dev->dev, "Failed to get channel %d conversion val\n", bit); goto out; }