Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3590144rdb; Sun, 10 Dec 2023 11:47:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7m3uwwXf4jM+5MOHsfFcEEqvv3a3VfhGn3LqZU7627K84ERI9LEWOuanc7HDBPijXt3Pn X-Received: by 2002:a05:6870:a54d:b0:1fb:1d1d:fca8 with SMTP id p13-20020a056870a54d00b001fb1d1dfca8mr3791989oal.48.1702237640417; Sun, 10 Dec 2023 11:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702237640; cv=none; d=google.com; s=arc-20160816; b=KVb701++FIuuE7deuqRXz3HmJGHwkJfvW7ijXm6CGyKacd/xq7HlkHJueFqpUqoLNh ivU2QobhrER1Pb2HhoT0Pw/9tstkONY5YV9JyZ2w+6Hw82ZZsNzGCntxGQ8ECqnXW5Qq LCbAeaf3Ej454GRDwzQP7a65+CEQMUWNkuQRngXzcRrRz/5619ugvdA1/kX/q9L54oFk g5wGuiEhhRjZtyv/L6zOnAC3rmxeMELRpeNi+HvlneOfh0ZlWEaj/bY7xhZmwGni+4xv CefrKePUYiUWP3wcHvO0gZ2fwmshJSBbQkyDG4hDMwrZTPvZIihKTA4dL2OmYIixbadP ffNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zfL3WzEuDXRtc2Yx9DpKvEpshQljhBnqTFJily+P2J4=; fh=1czjczYMLEeF5mIcgCNJsZGSvf4QUi9pKs0LGB1p1gI=; b=s1bF0m4jV6pFJKeGOVoaPCk5WlPSpdKvm0SwQ7UrJ9nZ0KnHyPSx7ipYi1ed5xEapv K1Qou8FmZLO3A/kT10DeG13WgszjCFXx2K8FU33rjOYA1LCiGeGg6TXH9dpMHfShNLo7 rasy7T/o4x58/2S62v8GB5C+uHWPwTI6dTVVSLRFXvYtpvpgB0Qd4cTpn2r9AtHi+gHg 4QoFLDWD84lTZClWk0RMERRJqOWkvgvVsyBWFssOswK7I4qrIUO2Dzht/vxaYBI+7ht6 nBrKri4cDeaJVIQ+Z3Y5t5/1m4P3H3U9qiNCxkGwyjkJPYYCHz0nmTigPbvqGYznkB/T Dykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mk/pk7j2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o3-20020a655203000000b005c66c662801si4769024pgp.182.2023.12.10.11.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 11:47:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mk/pk7j2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id B43878057935; Sun, 10 Dec 2023 11:47:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbjLJTql (ORCPT + 99 others); Sun, 10 Dec 2023 14:46:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjLJTqk (ORCPT ); Sun, 10 Dec 2023 14:46:40 -0500 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0C4ED for ; Sun, 10 Dec 2023 11:46:46 -0800 (PST) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5cfc3a48ab2so30865897b3.0 for ; Sun, 10 Dec 2023 11:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702237606; x=1702842406; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zfL3WzEuDXRtc2Yx9DpKvEpshQljhBnqTFJily+P2J4=; b=mk/pk7j2XNoWRptCydmxvtQoifeIfk5lXV8i3x87X7XPcTt2Zv629mUAWoA4hCow0L ZmpXSeKsB9jLwcg/cHVVVxmZv1XoolzR3ga6ZWdhX313iIsDB4GlFqEH5Ou8sH2oZGGz lFbNvdlf3NuTL2Lt9Xdo0GdYQcv4AAcGYg6NHPiWm/l6aXUSifM/N++7Px6yAG8KcnZd IUzc0O4VGJd1OhHxrSDXqzNGhhBelmRY3L+kmepjvh6Oi3sq4uPpqX+gwKBV3oqpRpBD c34uogyu1H/Gshum5NDM58PhgY9Ns7EVvtYDquF+fiVdq+P26vIoQFAhtIE11z7LeeP+ Qr1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702237606; x=1702842406; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zfL3WzEuDXRtc2Yx9DpKvEpshQljhBnqTFJily+P2J4=; b=ZQURhsO2ycYrZRXbPmj6RRDvM8RTHOVEtjkdXvlb8Q7qqMFnjSMKr/aI8HMODmkX24 xzXXXQFkOjqMHQnhtenWHBSJ3Fm2KBNRUqgBcTxgx3nBw2OL0Bg/4zarxB+Vi2dGOUGn 4/NFrMW6AuuQoG5AN82d9zPmzfkLdpOMAkf0BpC043KEpKtmvVVAkXrBb4aVfsphy2++ 5LxV4SqNaYHwog5NxdbGTPv3zE5ETx3OofQkPw5gNiejMErvaveTzYP6ouU8EI61lOHL W+PxFtLVAGMduwUoiXpCriXPNmfGvQScnUqDWzscF+3z44I7HO/0ubJ5A3E97YphmpYx COrg== X-Gm-Message-State: AOJu0YybSdw7lWyjEoVX6MeobKD1VYxr2QSDDSz8D10acU0Wq4dFZQje rsHZYh8GFGH01YaTH9Fm/H8Rf2BsXh/48vZzhO5R3A== X-Received: by 2002:a81:4fc7:0:b0:5d7:1941:abb with SMTP id d190-20020a814fc7000000b005d719410abbmr2574429ywb.86.1702237605793; Sun, 10 Dec 2023 11:46:45 -0800 (PST) MIME-Version: 1.0 References: <87dfa523-1882-417d-97b5-f606ff0099f9@moroto.mountain> In-Reply-To: <87dfa523-1882-417d-97b5-f606ff0099f9@moroto.mountain> From: Linus Walleij Date: Sun, 10 Dec 2023 20:46:34 +0100 Message-ID: Subject: Re: [PATCH] usb: fotg210-hcd: delete an incorrect bounds test To: Dan Carpenter Cc: Lee Jones , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 10 Dec 2023 11:47:17 -0800 (PST) Hi Dan, thanks for your patch! On Fri, Dec 8, 2023 at 10:23=E2=80=AFAM Dan Carpenter wrote: > 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 -=3D 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(). Wit= h > 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 <=3D 1) goto done;" but just deleting the test > is cleanest. This is a great fix! Thanks for going the extra mile and fix this when looking at the code. > Fixes: 1dd33a9f1b95 ("usb: fotg210: Collect pieces of dual mode controlle= r") That's the wrong commit. This commit just brings stuff together from old code... I believe it should be: Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver") It won't backport cleanly but it's the right commit. > Signed-off-by: Dan Carpenter With the right Fixes: Reviewed-by: Linus Walleij Yours, Linus Walleij