Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5256412rdb; Wed, 13 Dec 2023 03:49:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGM/NU2KBbav9IusKJVQ0eVoZw6r/uL7P3UnGA92b+hNik5U018/wjodZo7WFnnAKqNWs3I X-Received: by 2002:a17:902:b216:b0:1d0:a2b2:6b0d with SMTP id t22-20020a170902b21600b001d0a2b26b0dmr3629480plr.4.1702468166731; Wed, 13 Dec 2023 03:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702468166; cv=none; d=google.com; s=arc-20160816; b=vuMDlBa3oc5zpy8FdIFF5yNRCbIM316C2TFOZjub13mNO6LNNY0jwTIQcsZGQcO1G5 suP6dItLh5mYN7b/7uBk3HdnoG/Zp03vA2BgekjMm+pQOMI/z3OyQCaG7TLP9F4DumvN YLEZzpBQarEEW76S26Zs6eckOCyNrCxPVu81bbjW9Vy3szDB9E7li4ZLfHAsmUHoZCgr sEZEN2+C8+tLcoMuO7q/QAuiIi8fx1+Vys2LbxMlTH0EVaEbFl85oMSIVvMKgP3AUMBD B8/560SNpf5ys4DGKKpFkdsCcK6HBgbhuqvpZW6R5HgI0vKc0CJTJaVYCqJouHQ+94Vx 6vGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=W/D0nxBSPlK4RroXg/rfD3fuhaCV8HYpjjkVEFv2IkQ=; fh=Ve2V3kdIslt2W76P9XOOA26akgBD+M0uHE+Lel1VeKY=; b=0c8eJeZCwVxEMINCxBhZMVwBXsm96Os0hO2KOzO/8y7HbLqWtJ/DbzT9vOT2n/Cnog qW8LbTAyw9TBEZUk7PSCE8+Iv+hjRgzP55rn5/V94LpzaShWmTJ4wn6vuPApET1eDPjD mMoWkllP+6IWvLr6hTE1yBzc6sJaDxlblRAS5PDVeGEfueVDVWn/5wIiwJZ3RSIy5CGy yxViGoDvL11JMxIYppKVMItuzaAPI+T7pXZfh7z6+X0Z3IDrnbvpTYAnek2Nt/9vpe5f NWolXZnFFo/bhp5ITK8/QXNhMV5sP4obIsFreM437GleyyNGJzj8ZkX9kqlfTOFdLp5o TAwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMPgGAXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d18-20020a170902ced200b001d09e7f1e1esi9601747plg.429.2023.12.13.03.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 03:49:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMPgGAXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0FDA2803D031; Wed, 13 Dec 2023 03:49:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378181AbjLMLtF (ORCPT + 99 others); Wed, 13 Dec 2023 06:49:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235338AbjLMLtE (ORCPT ); Wed, 13 Dec 2023 06:49:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AFC0B0 for ; Wed, 13 Dec 2023 03:49:11 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C3CC433C7; Wed, 13 Dec 2023 11:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702468151; bh=gspTYGLvdxm7u26jTqUP9QE4qxk4YHzbc1GF9KCiV7E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jMPgGAXsD59orXEQwSuT3rrXWW+pwXyhY9fvZ8X6kscY5uXVHv+7pQdZ8goX2tQg2 YnuEt2SSM/+22Vslb33Z83s5HAblMc1uQOIaG4veD5qb26z++yizSosHRt/zeNJpDD sfJk9uv4C59KHCtmYD2t+RV+82qkDt21V06xknzZ4iINstdfEXqU4zfhj4uKCi/J+G EsWkDUP8byKlb9sAFOVfbuceSmcQJsTYHZu7QeY/MivUpoRnnF3fRE3KKFA+0Qu5dW aVht0LKmFKpZLjEFy5xGUQtQ/UH0eUsSY0jQ18zyyKdoMrXvxkyPosGgru0Aj5veHw UplXJHZ3IJyIA== Date: Wed, 13 Dec 2023 11:49:06 +0000 From: Lee Jones To: Dan Carpenter Cc: Linus Walleij , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] usb: fotg210-hcd: delete an incorrect bounds test Message-ID: <20231213114906.GL111411@google.com> References: <87dfa523-1882-417d-97b5-f606ff0099f9@moroto.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87dfa523-1882-417d-97b5-f606ff0099f9@moroto.mountain> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 13 Dec 2023 03:49:24 -0800 (PST) On Fri, 08 Dec 2023, 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 -= 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 > --- > drivers/usb/fotg210/fotg210-hcd.c | 3 --- > 1 file changed, 3 deletions(-) Super additional clean-up, thanks. Reviewed-by: Lee Jones > 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; > } > -- > 2.42.0 > -- Lee Jones [李琼斯]