From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, stable <stable@kernel.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Lee Jones <lee@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 42/47] usb: fotg210-hcd: delete an incorrect bounds test
Date: Fri, 5 Jan 2024 15:39:29 +0100 [thread overview]
Message-ID: <20240105143817.265120342@linuxfoundation.org> (raw)
In-Reply-To: <20240105143815.541462991@linuxfoundation.org>
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <dan.carpenter@linaro.org>
[ Upstream commit 7fbcd195e2b8cc952e4aeaeb50867b798040314c ]
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: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/ZXmwIwHe35wGfgzu@suswa
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/host/fotg210-hcd.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index f457e083a6f89..c0f727e793072 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -428,8 +428,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
temp = size;
size -= temp;
next += temp;
- if (temp == size)
- goto done;
}
temp = snprintf(next, size, "\n");
@@ -439,7 +437,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
size -= temp;
next += temp;
-done:
*sizep = size;
*nextp = next;
}
--
2.43.0
next prev parent reply other threads:[~2024-01-05 14:44 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 14:38 [PATCH 5.4 00/47] 5.4.266-rc1 review Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 01/47] ALSA: hda/realtek: Enable headset on Lenovo M90 Gen5 Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 02/47] ksmbd: fix wrong name of SMB2_CREATE_ALLOCATION_SIZE Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 03/47] ARM: OMAP2+: Fix null pointer dereference and memory leak in omap_soc_device_init Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 04/47] reset: Fix crash when freeing non-existent optional resets Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 05/47] s390/vx: fix save/restore of fpu kernel context Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 06/47] wifi: mac80211: mesh_plink: fix matches_local logic Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 07/47] Revert "net/mlx5e: fix double free of encap_header" Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 08/47] net/mlx5: improve some comments Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 09/47] net/mlx5: Fix fw tracer first block check Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 10/47] net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by representors Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 11/47] net: sched: ife: fix potential use-after-free Greg Kroah-Hartman
2024-01-05 14:38 ` [PATCH 5.4 12/47] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 13/47] net/rose: fix races in rose_kill_by_device() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 14/47] net: check vlan filter feature in vlan_vids_add_by_dev() and vlan_vids_del_by_dev() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 15/47] afs: Fix the dynamic roots d_delete to always delete unused dentries Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 16/47] afs: Fix dynamic root lookup DNS check Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 17/47] net: warn if gso_type isnt set for a GSO SKB Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 18/47] net: check dev->gso_max_size in gso_features_check() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 19/47] afs: Fix overwriting of result of DNS query Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 20/47] i2c: aspeed: Handle the coalesced stop conditions with the start conditions Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 21/47] pinctrl: at91-pio4: use dedicated lock class for IRQ Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 22/47] ALSA: hda/hdmi: Add quirk to force pin connectivity on NUC10 Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 23/47] ALSA: hda/hdmi: add force-connect quirk for NUC5CPYB Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 24/47] smb: client: fix NULL deref in asn1_ber_decoder() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 25/47] btrfs: do not allow non subvolume root targets for snapshot Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 26/47] interconnect: Treat xlate() returning NULL node as an error Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 27/47] iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 28/47] Input: ipaq-micro-keys - add error handling for devm_kmemdup Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 29/47] scsi: bnx2fc: Fix skb double free in bnx2fc_rcv() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 30/47] iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time table Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 31/47] iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 32/47] wifi: cfg80211: Add my certificate Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 33/47] wifi: cfg80211: fix certs build to not depend on file order Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 34/47] USB: serial: ftdi_sio: update Actisense PIDs constant names Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 35/47] USB: serial: option: add Quectel EG912Y module support Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 36/47] USB: serial: option: add Foxconn T99W265 with new baseline Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 37/47] USB: serial: option: add Quectel RM500Q R13 firmware support Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 38/47] Bluetooth: hci_event: Fix not checking if HCI_OP_INQUIRY has been sent Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 39/47] net: 9p: avoid freeing uninit memory in p9pdu_vreadf Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 40/47] net: rfkill: gpio: set GPIO direction Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 41/47] x86/alternatives: Sync core before enabling interrupts Greg Kroah-Hartman
2024-01-05 14:39 ` Greg Kroah-Hartman [this message]
2024-01-05 14:39 ` [PATCH 5.4 43/47] smb: client: fix OOB in smbCalcSize() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 44/47] bus: ti-sysc: Use fsleep() instead of usleep_range() in sysc_reset() Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 45/47] bus: ti-sysc: Flush posted write only after srst_udelay Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 46/47] ring-buffer: Fix wake ups when buffer_percent is set to 100 Greg Kroah-Hartman
2024-01-05 14:39 ` [PATCH 5.4 47/47] block: Dont invalidate pagecache for invalid falloc modes Greg Kroah-Hartman
2024-01-05 16:04 ` [PATCH 5.4 00/47] 5.4.266-rc1 review Daniel Díaz
2024-01-05 17:01 ` Daniel Díaz
2024-01-06 8:38 ` Greg Kroah-Hartman
2024-01-05 21:51 ` Shreeya Patel
2024-01-06 8:39 ` Greg Kroah-Hartman
2024-01-06 5:57 ` Harshit Mogalapalli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240105143817.265120342@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=dan.carpenter@linaro.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).