From patchwork Thu Aug 19 18:09:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 12447717 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 BE618C4338F for ; Thu, 19 Aug 2021 18:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6FC160F5E for ; Thu, 19 Aug 2021 18:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234244AbhHSSK1 (ORCPT ); Thu, 19 Aug 2021 14:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbhHSSK0 (ORCPT ); Thu, 19 Aug 2021 14:10:26 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5873EC061575 for ; Thu, 19 Aug 2021 11:09:50 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id v20-20020a1cf714000000b002e71f4d2026so30326wmh.1 for ; Thu, 19 Aug 2021 11:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JmCDVcDPr5bxst7uNZbmQzVkDOfalyIwULzIMEWLkMY=; b=ThyHI7NGLfwsYBdsiEWavAFR269WKTFwFqw+dbgueZdpT0ho/GVW3YLIa0azxxZCt2 WohB25kgegHe0H8VfBtf2B9Vh+27zelFFTLboiOdqXLUZCWdOLah+8dy04Sre3lcDXT6 ZpU210DMxTCtZG8xIjWd30HC0c+vcIiJeQeppglCPfJZG5xHSUtoilMBUQOVuYY+LDP3 n9KKs99OX2h6L61kvl78J/5Yi1ZC75SSKEuWaD3mzMM77I5trd8wvlzdWrUqjNP0Nu8N RcqhOF4USqWplqZ+f2jjohZeoubnxp5LDj2zMpETV/OQsBxPWj7umwhp+/Gw2Z0IV9uj bw6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JmCDVcDPr5bxst7uNZbmQzVkDOfalyIwULzIMEWLkMY=; b=pQ/C99QpuQNZPedbDClINsmSSx2b7Rocw1BfMOGdZJjLb2leWNbRvuKr6ZcuLHqn8d fq/KB2Mbgdlb7FCxXs3hx8u4DFZUPIOiNasIZsLa5jCYmJhHLkMsrJ/U2OYj3cozJL2H Syd7D/EI0/B2TS9YrGO0xxearkEn3r4jt74Du0fq/v3mWXbbXRIHhgnLt6S0/BcUgcfN cFq63Z6N1wpAbuyhF/OVroQ3G4zMrrzSetIncQnLXQCXVA9AJWVX7VOXp3nSdpXJ6Yay VaP7IAIHnvIqQjFoodd6rTyjSyVApVuLYCTqeMTnHnwxv9vyrTDFkUIPs4Zh8CTluvB2 soqw== X-Gm-Message-State: AOAM533A3n2Gbi4IoNDxcfkagFGWmERVpoiwxVGXgreX8vTO85RcriLy 1XWcMwgZW8h3+E1RKuKE3Xo3PQ== X-Google-Smtp-Source: ABdhPJxdJA9tboezQGAAsTyNJHsr/Gf2lR1hvZEeXjIhznl7KXl00joXD0Zg8C4c/XKRZv96DHyo+Q== X-Received: by 2002:a1c:3909:: with SMTP id g9mr14794276wma.63.1629396589009; Thu, 19 Aug 2021 11:09:49 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id h16sm3625668wre.52.2021.08.19.11.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 11:09:48 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 1/5] usb: isp1760: ignore return value for bus change pattern Date: Thu, 19 Aug 2021 19:09:25 +0100 Message-Id: <20210819180929.1327349-2-rui.silva@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210819180929.1327349-1-rui.silva@linaro.org> References: <20210819180929.1327349-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We do not care about the return value of that read between the scratch register write and read, we really just want to make sure that the pattern in the bus get changed to make sure we are testing correctly the scratch pattern. Clang-analyzer complains about the never read scratch variable: >> drivers/usb/isp1760/isp1760-hcd.c:735:2: warning: Value stored to 'scratch' is never read [clang-analyzer-deadcode.DeadStores] scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); Just ignore the return value of that CHIP_ID_HIGH read, add more information to the comment above why we are doing this. And as at it, just do a small format change in the error message bellow. Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-hcd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index 825be736be33..2a21fe5aa7a8 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -731,11 +731,15 @@ static int isp1760_hc_setup(struct usb_hcd *hcd) isp1760_hcd_write(hcd, HC_SCRATCH, pattern); - /* Change bus pattern */ - scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); + /* + * we do not care about the read value here we just want to + * change bus pattern. + */ + isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); scratch = isp1760_hcd_read(hcd, HC_SCRATCH); if (scratch != pattern) { - dev_err(hcd->self.controller, "Scratch test failed. 0x%08x\n", scratch); + dev_err(hcd->self.controller, "Scratch test failed. 0x%08x\n", + scratch); return -ENODEV; } From patchwork Thu Aug 19 18:09:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 12447719 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 18DECC4338F for ; Thu, 19 Aug 2021 18:09:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0228B6109F for ; Thu, 19 Aug 2021 18:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234261AbhHSSK3 (ORCPT ); Thu, 19 Aug 2021 14:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbhHSSK3 (ORCPT ); Thu, 19 Aug 2021 14:10:29 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921C6C061575 for ; Thu, 19 Aug 2021 11:09:52 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id f13-20020a1c6a0d000000b002e6fd0b0b3fso5754651wmc.3 for ; Thu, 19 Aug 2021 11:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nJFsB0vNTcvxAccxAs8X/3nZKeh6jAZ98Q3ZjWO+LEQ=; b=Wv1an5VdNrbgraw7EX4H4zOhAWUPNg2I0JM/753YIzCbjA5Fx6Kn8wDX9L0cBzoKh7 S5UIdzHCbLSh7anQxjs6GFdS357toSGUTNdnkKtneCQk3+XSV1/gOTSL9IDzzNRR0PRN eLYOj7pHYzFoKVUJKyvy3+rXMHhFItIDPqT+7fnRqg/Xf6gVNVnlqUu6cJd4IK05bUE/ Gna/oPee5FUhDuYAQ2Zv8EejH9bnKsyWIvLJI93DaXnvURx/eWridh/8WuOY7cHNavhO vi1qI0oA9q29RKMTROdLeWNCbmV99y40fpwVTalsMFcDcn7y6QHNiofcQF1dE6NajH8+ +1sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nJFsB0vNTcvxAccxAs8X/3nZKeh6jAZ98Q3ZjWO+LEQ=; b=hMApu5e31ie1yHCyUNnJ2UA2j7ogxvylJMr/ly1//D3oaRapxxXAUe4atVQjAPK1E4 JZdNB7oXYJi/okhpSfhnIGlhVFuurKhlVwiCgT1Hpu/s/VMbtv2LMlp7cX5MzjoUzJYh Yu6cHcS3yiFJbHKiO/4F3RX+nSZ6ElcxVgSnon3pTy77KXZM4nafBeV6Qkp6dJwGqoQP csGI3fmKH8VxofZ6oU7R+ndLKu8e/9qhK3cjOOJ6uAa25zCZdDx86UMnl42JMGYUbdr6 wXzVMWUHhVJu6djyvQbDKsRZKd/zHEwxnT4irnBdRDjzhJj5qm+6kTh/LNbUko3Hl2Wo sp5Q== X-Gm-Message-State: AOAM532u47NZ+3LiUo2qMJkdMN/pFYgJnmPk11MKEy+12d8z6fh5cFbE /YzzApqrnMWTBwrCoLoTuzxO9w== X-Google-Smtp-Source: ABdhPJwFTgzzn3g4DphYHWM09Tq2x3PPewtmKX76D6hrMXygREr02nxXG8U3jGnyP147GVC1aDqv/A== X-Received: by 2002:a7b:cf0c:: with SMTP id l12mr25984wmg.62.1629396591112; Thu, 19 Aug 2021 11:09:51 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id h16sm3625668wre.52.2021.08.19.11.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 11:09:50 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 2/5] usb: isp1760: check maxpacketsize before using it Date: Thu, 19 Aug 2021 19:09:26 +0100 Message-Id: <20210819180929.1327349-3-rui.silva@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210819180929.1327349-1-rui.silva@linaro.org> References: <20210819180929.1327349-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When checking if we need one more packet on a bulk pipe we may, even though not probable at all, get there with a zero maxpacketsize. In that case for sure no packet, no even a one more, will be allocated. This will clean the clang-analyzer warning: drivers/usb/isp1760/isp1760-hcd.c:1856:38: warning: Division by zero [clang-analyzer-core.DivideZero] && !(urb->transfer_buffer_length % Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index 2a21fe5aa7a8..5c947a1eae49 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -1854,7 +1854,7 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type = OUT_PID; else packet_type = IN_PID; - } else if (usb_pipebulk(urb->pipe) + } else if (usb_pipebulk(urb->pipe) && maxpacketsize && (urb->transfer_flags & URB_ZERO_PACKET) && !(urb->transfer_buffer_length % maxpacketsize)) { From patchwork Thu Aug 19 18:09:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 12447721 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 CCA38C432BE for ; Thu, 19 Aug 2021 18:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B72E2610A1 for ; Thu, 19 Aug 2021 18:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234280AbhHSSKb (ORCPT ); Thu, 19 Aug 2021 14:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbhHSSKa (ORCPT ); Thu, 19 Aug 2021 14:10:30 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DECC061575 for ; Thu, 19 Aug 2021 11:09:54 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id g138so4344548wmg.4 for ; Thu, 19 Aug 2021 11:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kIhATUwU3sUQYA4q+gJG6oepV84++lZlrfSYVpZi/Vs=; b=PLoEyfbFNDueucBTSH5khGQEwCDcfGBRfIgUqzg14x8DgeVgU3k+CX+70c0MxLdFFE Y4Z6YDTWPrzIw65gTljM1rv+oTz00eGTmLWlA7pPrqxBdnlQsIEtVz0dB75JQRiCSNNP n7tfNmXz45GkVHP8ibapyqgcWoCQX5sBiKI8X4jm6sInMk5k0vzGsOtL7OVEmPa1zxNj cTQbOTJc7+27Ef+9WuRFk8XBIAQDoTqZ/7BSBBWVIsfnT7HX9I7TRcTURCg+SXtZFH4E q9C02z6EVunOf/Ai/tpugr513MlsF1OlNAOGj+D8sD5f9pjJndz1j+XSWuuJxfpHyrEX wg/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kIhATUwU3sUQYA4q+gJG6oepV84++lZlrfSYVpZi/Vs=; b=SYClS6kLCSQtxjOMVRUJGKH61hykvUQNWW4GeZfk5vw5XROHcHY0tQ2Ccpo5NwyKOg rVRcElQaDMlICRHktLD8ih0VV5t07Aea5w8H3vxMwqRC/nCJa3E1oK2TZWEv5Jtkt0qk 5wkQiNzeRxdO1NhcjkYuNFMPkTZb9SEEHpJ5LIrS+cmD0KSN2mZ2y9+Z6Lcf9g2570WX EsMPUSVxRp2RTTXLtX+VpwmBmOLBFqB7M9HgpCxwh0upLxzEUOqrK4fzIz5y/xN1GJHM /T/dlpjJd54hv9ApNRPqAeAnbfhLpObLxFt/rWEY5WrxsY7IkEeZBS0ae20PHyEEH1wd 1pKg== X-Gm-Message-State: AOAM531PT4BxZLu0lq/mMxlef5nBXWjtuPaWG5oWT6nBUTJvXPoPO/tA ohQPzz1nztX+SUp9vq6AR+7ozQ== X-Google-Smtp-Source: ABdhPJyHAueAWAdjT2HenovBVao4pJCrlqyEVlzTfOl855XskwFNPZ9in4AlIVDCGrnsa0KJi97TJQ== X-Received: by 2002:a05:600c:3591:: with SMTP id p17mr15373wmq.134.1629396592911; Thu, 19 Aug 2021 11:09:52 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id h16sm3625668wre.52.2021.08.19.11.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 11:09:52 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 3/5] usb: isp1760: do not reset retval Date: Thu, 19 Aug 2021 19:09:27 +0100 Message-Id: <20210819180929.1327349-4-rui.silva@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210819180929.1327349-1-rui.silva@linaro.org> References: <20210819180929.1327349-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We do not really need to reset retval before get used bellow. This will avoid the clang-analyzer warning: drivers/usb/isp1760/isp1760-hcd.c:1919:2: warning: Value stored to 'retval' is never read [clang-analyzer-deadcode.DeadStores] retval = 0; Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-hcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index 5c947a1eae49..aed2714ce0cf 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -1919,7 +1919,6 @@ static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (list_empty(&new_qtds)) return -ENOMEM; - retval = 0; spin_lock_irqsave(&priv->lock, spinflags); if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { From patchwork Thu Aug 19 18:09:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 12447723 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 D4DF9C4320A for ; Thu, 19 Aug 2021 18:09:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB9176109F for ; Thu, 19 Aug 2021 18:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234306AbhHSSKe (ORCPT ); Thu, 19 Aug 2021 14:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbhHSSKc (ORCPT ); Thu, 19 Aug 2021 14:10:32 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE09C061575 for ; Thu, 19 Aug 2021 11:09:55 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id q11so10378334wrr.9 for ; Thu, 19 Aug 2021 11:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pMSofRuLOOEM7S4GLf+GNrXNSMWfOcGXM1C31TKENBk=; b=az+O+V4GOiSZhHL7uvCPOkIyBa8xVmKZrl3tWgHLCmOjeqf6KknZHqU68B41Fhr2ur Ios8Ca0LKJRRSYNdfWN3Y0s8Ud5D5JRnAjkvIGH75LYDdPiGgBpWYsdG9e8Joi8K/T2N w8ZhQH48K+A0MBjdUxhfCasrSbp+Dgqge0U6zFZopi35HYr/P11eG6K21cSx02I7vqiF QNgJoDj9OXqufwi08TftkfJRnMc8yjbESRNiYh4ZVuvGo/CPVbABd9LZTdc+QP0tOTmq QOAzIj6oTiQq1I5443TENPhiR06jdVK6Y+nDMsa1IRIVjjhGfkzwcBfRHXFxMP2NBzIX UckA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pMSofRuLOOEM7S4GLf+GNrXNSMWfOcGXM1C31TKENBk=; b=j9IHTqqnTQyzwi4qQdPAM5gLOg8R5MsaS0BsWwJ+cjLDK64edEu452z8+TxJIFlfPy lYbAlu3+zIC3QSKKVEWpovqVwq8MsadpiCSH1w8U+HltfabZEt3NeDTWikbR98R+VmNZ pQWkIpm9vK37DfaghT+7bDybNG2PexLMqVVf+x8fpgJHi1M6sxyrVJvBc4scgNQbjI72 qjCHgrEvsS5CAfzMMlTreKuz7bPYmZgFDqCkjdZgOR1UR2N9/gb8ybmIUieGN4/hpZje yo5FgFCdq32utdxqvMiWEWOguJK1Bs0wBC1OdPpZ/bez9ub6Ty9XEzPo6oPX15FNPy6z pNRQ== X-Gm-Message-State: AOAM533HOVfBHQ9JS9shGqASd3j/En8vEgaSIEednFkXqgTwLfkVgFy4 rdCfNOYZORiFoYKwPhJQtQMutA== X-Google-Smtp-Source: ABdhPJxWQhiOG2sZdGOBg7F/TsBsSBomEuQfVHoZFtDHuMyUUovWvR4bzDYBHn9vtAIxb81LSi3Mag== X-Received: by 2002:a5d:6301:: with SMTP id i1mr5271775wru.423.1629396594614; Thu, 19 Aug 2021 11:09:54 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id h16sm3625668wre.52.2021.08.19.11.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 11:09:54 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 4/5] usb: isp1760: do not shift in uninitialized slot Date: Thu, 19 Aug 2021 19:09:28 +0100 Message-Id: <20210819180929.1327349-5-rui.silva@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210819180929.1327349-1-rui.silva@linaro.org> References: <20210819180929.1327349-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Even though it is not expected, and would trigger a WARN_ON, killing a transfer in a uninitialized slot this sequence is warned by clang analyzer, twice: drivers/usb/isp1760/isp1760-hcd.c:1976:18: warning: The result of the left shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult] skip_map |= (1 << qh->slot); drivers/usb/isp1760/isp1760-hcd.c:1983:18: warning: The result of the left shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult] skip_map |= (1 << qh->slot); Only set skip map if slot is active. Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-hcd.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index aed2714ce0cf..bf8ab3fe2e5a 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -1974,16 +1974,20 @@ static void kill_transfer(struct usb_hcd *hcd, struct urb *urb, /* We need to forcefully reclaim the slot since some transfers never return, e.g. interrupt transfers and NAKed bulk transfers. */ if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) { - skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP); - skip_map |= (1 << qh->slot); - isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map); - ndelay(100); + if (qh->slot != -1) { + skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP); + skip_map |= (1 << qh->slot); + isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map); + ndelay(100); + } priv->atl_slots[qh->slot].qh = NULL; priv->atl_slots[qh->slot].qtd = NULL; } else { - skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP); - skip_map |= (1 << qh->slot); - isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map); + if (qh->slot != -1) { + skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP); + skip_map |= (1 << qh->slot); + isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map); + } priv->int_slots[qh->slot].qh = NULL; priv->int_slots[qh->slot].qtd = NULL; } From patchwork Thu Aug 19 18:09:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 12447725 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 32BCBC4320E for ; Thu, 19 Aug 2021 18:09:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 155A06109F for ; Thu, 19 Aug 2021 18:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234317AbhHSSKe (ORCPT ); Thu, 19 Aug 2021 14:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbhHSSKe (ORCPT ); Thu, 19 Aug 2021 14:10:34 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B5C9C061756 for ; Thu, 19 Aug 2021 11:09:57 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k29so10367021wrd.7 for ; Thu, 19 Aug 2021 11:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=98TIgGcF5QpWM5jqnKUiMqwzL4ec7B61vjYW5N3VNTw=; b=VLTXxX1brKA+iPAowPeK0fPIq0jgshzN2MD7g8aNen0SZOUnffRmOo5vPmn6+vpLQh y955nkaufeHt8PRBafJHIZeIkVm6EXt6Kk+j691BkSgzQGWAqNPUnZpdHECgnClOlpyB V4B/lYPatYf/ZFRZX+awPSO+yriIq9V09/BSZOg05BlOy2Q2ea/7p70OxRDqRCihUJoV JwjRuN81oER0gtQROOLbMEq3QhwCMbQ3uqW8lRbsXb3fyCWonGXZ91tdB2Y1GF1e07zp ibpSFHrEwA887GlCIMOA86+PICG/T7IesFzR31DdMresrstLeWHKzqIrEAuZp1UQAeDF zLgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=98TIgGcF5QpWM5jqnKUiMqwzL4ec7B61vjYW5N3VNTw=; b=Z32Tyleh5U1dJgPXln4uglIDCfAUR6wDH1XVs9SfuvFxVEwhenB3hXCc8F54PR8U9h nFEp+L76TXSBSW4tdpCo8bozVvNbUimtK8rjBUU/SC1l7juRVF9Lpbq95rYr+Xgz0Y5D sobnBOfu3OyBCgno/sobM+JJpv2aZPWyI2oQ8KrEaMQv7G+pGMh0puK47df4Ahc6Kjam bbbYEkVy/iSQTgQu1CiLmAKGh+SR7Lx9hjT3gEZzTMvmi0QDS0aoXvJtmmXrfkPTXYmX VhXnVWs1cRaKygpquxNjOx34bahdF/kEJqbYhQ6yO9fjrvd/PYefWoq+N82vTQK2ADfP Dsgw== X-Gm-Message-State: AOAM533lGX0aZ6CnlBhPLT/1JyFdo9AiDn086ZQOwWdqmfthx4xWhdU0 ZQ0hY0KbXtTazW+M/JSwnMSgnw== X-Google-Smtp-Source: ABdhPJwf/hyB392NG3LR3D3QHOYmRT5sfFKJtFztXe2QzkrYJvtUCNClj91zOyUYttzBBIcfAjNf5g== X-Received: by 2002:adf:d4c7:: with SMTP id w7mr5511212wrk.301.1629396596272; Thu, 19 Aug 2021 11:09:56 -0700 (PDT) Received: from arch-thunder.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id h16sm3625668wre.52.2021.08.19.11.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 11:09:56 -0700 (PDT) From: Rui Miguel Silva To: Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH 5/5] usb: isp1760: clean never read udc_enabled warning Date: Thu, 19 Aug 2021 19:09:29 +0100 Message-Id: <20210819180929.1327349-6-rui.silva@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210819180929.1327349-1-rui.silva@linaro.org> References: <20210819180929.1327349-1-rui.silva@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When CONFIG_USB_ISP1761_UDC is not enabled the udc_enabled variable is never used since it is short circuited before in the logic operations. This would trigger the following warning by clang analyzer: drivers/usb/isp1760/isp1760-core.c:490:2: warning: Value stored to 'udc_enabled' is never read [clang-analyzer-deadcode.DeadStores] udc_enabled = ((devflags & ISP1760_FLAG_ISP1763) || ^ drivers/usb/isp1760/isp1760-core.c:490:2: note: Value stored to 'udc_enabled' is never read Just swap the other of the operands in the logic operations. Signed-off-by: Rui Miguel Silva --- drivers/usb/isp1760/isp1760-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/isp1760/isp1760-core.c b/drivers/usb/isp1760/isp1760-core.c index ff07e2890692..cb70f9d63cdd 100644 --- a/drivers/usb/isp1760/isp1760-core.c +++ b/drivers/usb/isp1760/isp1760-core.c @@ -491,7 +491,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, (devflags & ISP1760_FLAG_ISP1761)); if ((!IS_ENABLED(CONFIG_USB_ISP1760_HCD) || usb_disabled()) && - (!IS_ENABLED(CONFIG_USB_ISP1761_UDC) || !udc_enabled)) + (!udc_enabled || !IS_ENABLED(CONFIG_USB_ISP1761_UDC))) return -ENODEV; isp = devm_kzalloc(dev, sizeof(*isp), GFP_KERNEL); @@ -571,7 +571,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, return ret; } - if (IS_ENABLED(CONFIG_USB_ISP1761_UDC) && udc_enabled) { + if (udc_enabled && IS_ENABLED(CONFIG_USB_ISP1761_UDC)) { ret = isp1760_udc_register(isp, irq, irqflags); if (ret < 0) { isp1760_hcd_unregister(hcd);