From patchwork Fri Dec 8 09:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 175693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5338365vqy; Fri, 8 Dec 2023 01:23:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFm/E+lXRHe2MXVzqIR60gdkvh1Jn2TSqPR04kzvPVcYfsQRSeouseWiDhSnKoLIWCZ6AbR X-Received: by 2002:a05:6a00:6c9e:b0:6cb:a93c:dfd1 with SMTP id jc30-20020a056a006c9e00b006cba93cdfd1mr4644627pfb.14.1702027422772; Fri, 08 Dec 2023 01:23:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702027422; cv=none; d=google.com; s=arc-20160816; b=xqYkXbYiQso8Ux1VV+I23JUyCmSl9ffjRRF8+b7Lt37arxnjvKiJoGq+hVjeZZRyRE ocUeh51bPYOe+UAI4EaMwSaE8IQil/R5EjBw35O2HT3PGAOMnXtL/PEA+z0ZdeZXfB4V 3cPQ62ztdxWTa6PiT9NYIQHD9dZX/nNg+ypxf1AljXE4Dsr9a0PPmHIj4d2KC4y/8Aq+ 5so6vNDqs1zbuyLgCNPS+sQ8oCKmTlaNSl8Qh8cB6wzGPMHd8DubTa3Vt+JLxV01w4DV uVOIGJSCIg1xSU7uFkzICjQMchysbH0qgFwHdTbjPLwXbCaRE2ZB5CXXvTpdQGhjG2LA mUHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=sF5azUrnouYTUY2Q8ByvyW/W1CG+UKUpVM173B2tLAY=; fh=ZbCQPu0FctmlODUV4hl0D3nNviDtCWsXxDm5W5r7MJY=; b=DX3tuSK43U8X17SZaASp7x7mvh7wUSU0Ay3b2FgpqnXRvnhyN/krK13oihNO7tv6S/ VuLgcnxSKqBF+c4qUKQvqgpLXy2yUXAtBtwJx2fkDb4ux4gG+EijTwrxSQYEtpQWMAKJ 0ywq/evVv83Pw0xO9ozraf/7MT2Nk0Bf6iJLAyzWVZm6lAQSF4ZymSiXfTVxa9QfWC9g SWiBVWHvPzor7MqtxJJqMUsrLYoDOov7rjybhzr/X+RzDWcG5t35B7HcNeo/xiUliYOq SvdM1v/ZABXo6sjAqilbTZNX+CrfSw7ux+1pnf11jmof3qkW9mCYDk13fvWviR7SjsgS dI3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVp4KS2j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p24-20020aa78618000000b006ce544ed22csi1229544pfn.128.2023.12.08.01.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 01:23:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVp4KS2j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 401428184516; Fri, 8 Dec 2023 01:23:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbjLHJX3 (ORCPT + 99 others); Fri, 8 Dec 2023 04:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbjLHJX2 (ORCPT ); Fri, 8 Dec 2023 04:23:28 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F06171D for ; Fri, 8 Dec 2023 01:23:34 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40c09dfd82aso25210335e9.0 for ; Fri, 08 Dec 2023 01:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702027413; x=1702632213; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sF5azUrnouYTUY2Q8ByvyW/W1CG+UKUpVM173B2tLAY=; b=lVp4KS2jwtC92RaW/Pw3mhwR4W6yElFDSiw6awBe+4faQI9D8SQYt/YyEgF7rlda4i 47IrEblk9TZjYlbml+lpsD5qnUqj3XXtDEAYoON9LF9qJNVom5FYn5h2WviYmoXs4N4T xv+Ka/1tTPC/bsCmBjQ05btj2SeofEXkWvEsKax3JZ/iquqV/jXjW17AD2IFs64KbQWs Smgr9dVxzARxVIceiMXpzxsAx0kAnJllY3YhBm0kwBckT0Z16GHt936Fj+sAmt9MpFjv LJ0Ao3mqFyJNM/2Fid2dlS+odixbj7DqI/NFI3JIqZvaiXt34ffWJynQ2TxiO3YeNFZK UQbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702027413; x=1702632213; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sF5azUrnouYTUY2Q8ByvyW/W1CG+UKUpVM173B2tLAY=; b=ezsp7wjzPHoeJ8N+NKsWxviq1NzJDeLzabr6yQPcymsQiPUHkcgI6oHZ1oPJjPMct5 eXNE2zrXZNa1LNccRZSAXi3VyK3Dol0S5r2dX5D7k6PL0OkwlqqkZR+nu4tqUgyMX89v bM407iJMw2jixFk+s/FY2hc4CBVbs5hbytpjBkqppbRCUXYmP+Nf9W3EYMAWeFSTWwG1 uSUVpanMDmkETa+VzdPOGHFEoBbQws17dqs5P0SVZg72yIVaY9rV0Axo1tucZ8wC5mQh Zl5madJCB7Ms01b7j6i8+/qxOAByIJ638qCR0kIhrTw7M04g9km8EW2McNPSUbPsB3OP kaDg== X-Gm-Message-State: AOJu0YxEXGUml7BJZxYCUem8XeuAXKBmbSyzcFYP3Cp7W2643hyoc9FR VQbzpI4AsbEERXQy1CQN/BgbgA== X-Received: by 2002:a05:600c:444a:b0:40b:5e21:dd3c with SMTP id v10-20020a05600c444a00b0040b5e21dd3cmr2527781wmn.106.1702027413258; Fri, 08 Dec 2023 01:23:33 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id d12-20020a05600c3acc00b0040b5377cf03sm4537310wms.1.2023.12.08.01.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 01:23:32 -0800 (PST) Date: Fri, 8 Dec 2023 12:23:28 +0300 From: Dan Carpenter To: Linus Walleij , Lee Jones Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] usb: fotg210-hcd: delete an incorrect bounds test Message-ID: <87dfa523-1882-417d-97b5-f606ff0099f9@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 01:23:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784705107252757763 X-GMAIL-MSGID: 1784705107252757763 Here "temp" is the number of characters that we have written and "size" is the size of the buffer. The intent was clearly to say that if we have written to the end of the buffer then stop. However, for that to work the comparison should have been done on the original "size" value instead of the "size -= temp" value. Not only will that not trigger when we want to, but there is a small chance that it will trigger incorrectly before we want it to and we break from the loop slightly earlier than intended. This code was recently changed from using snprintf() to scnprintf(). With snprintf() we likely would have continued looping and passed a negative size parameter to snprintf(). This would have triggered an annoying WARN(). Now that we have converted to scnprintf() "size" will never drop below 1 and there is no real need for this test. We could change the condition to "if (temp <= 1) goto done;" but just deleting the test is cleanest. Fixes: 1dd33a9f1b95 ("usb: fotg210: Collect pieces of dual mode controller") Signed-off-by: Dan Carpenter Reviewed-by: Linus Walleij Reviewed-by: Lee Jones --- drivers/usb/fotg210/fotg210-hcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c index b2f8b53cc8ef..8c5aaf860635 100644 --- a/drivers/usb/fotg210/fotg210-hcd.c +++ b/drivers/usb/fotg210/fotg210-hcd.c @@ -426,8 +426,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, td->urb); size -= temp; next += temp; - if (temp == size) - goto done; } temp = scnprintf(next, size, "\n"); @@ -435,7 +433,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, size -= temp; next += temp; -done: *sizep = size; *nextp = next; }