Hi Greg and all,
This series performs a set of cleanups, correctness fixes, and
remaining TODO removals across the Greybus drivers in
drivers/staging/greybus.
Greybus has existed in staging for a long time, and many FIXMEs,
outdated comments, and partial implementations had accumulated over the
years. While reviewing and compile-testing the drivers I found a number of
places where the comments were obsolete, logic was incomplete, or newer
subsystem APIs had evolved.
This series addresses those issues without changing any fundamental
design or architecture. All changes are self-contained, straightforward,
and focues on improving correctness and maintainability.
The patches include:
* Removal of obsolete FIXMEs that no longer reflect the current code
or hardware behavior.
* Correctness fixes in several protocol drivers (UART, RAW, USB,
Loopback, Firmware core, Audio).
* Small improvements to error handling and shutdown paths.
* Cleanup of commented-out or dead code.
* Removal of the now-completed GPIO and PWM TODO items.
* Removal of the empty Greybus TODO file.
All patches were compile-tested with COMPILE_TEST=y and all Greybus
options enabled. Runtime smoke testing was performed where possible.
This series does not attempt to graduate Greybus out of staging; these
changes are preparatory cleanups only.
Thanks for your time and review.
Ayaan Mirza Baig (13):
staging: greybus: Remove completed GPIO conversion TODO item
staging: greybus: pwm: move activation into pwm apply and remove
request()
staging: greybus: remove empty TODO file
staging: greybus: audio: remove obsolete INPUT_PROP_NO_DUMMY_RELEASE
FIXME
staging: greybus: audio: remove obsolete FIXME and document topology
ownership
staging: greybus: bootrom: remove obsolete FIXME about SVC parallel
event handling
staging: greybus: bootrom: remove obsolete FIXME around firmware
filename logging
staging: greybus: fw-core: remove obsolete S2 Loader runtime PM FIXME
staging: greybus: loopback: remove incorrect FIXME about async wait
staging: greybus: raw: handle disconnect while chardev is open
staging: greybus: uart: clear unsupported termios bits
staging: greybus: usb: validate hub control response length
staging: greybus: usb: remove obsolete FIXME about bridged-PHY support
drivers/staging/greybus/TODO | 5 -----
drivers/staging/greybus/audio_codec.c | 7 +------
drivers/staging/greybus/audio_module.c | 6 ++++--
drivers/staging/greybus/bootrom.c | 10 ++--------
drivers/staging/greybus/fw-core.c | 4 ++--
drivers/staging/greybus/loopback.c | 6 +-----
drivers/staging/greybus/pwm.c | 19 +++++++++++--------
drivers/staging/greybus/raw.c | 18 ++++++++++++++++--
drivers/staging/greybus/uart.c | 10 ++++++++--
drivers/staging/greybus/usb.c | 23 ++++++++---------------
10 files changed, 53 insertions(+), 55 deletions(-)
delete mode 100644 drivers/staging/greybus/TODO
--
2.51.0
The firmware_tag string comes from userspace and may not be NUL
terminated. strlcpy() performs strlen() on the source buffer, which can
read past the end and potentially cause an Oops. strscpy() avoids this
and guarantees NUL termination without overflowing the destination.
Signed-off-by: Dharanitharan R <dharanitharan725(a)gmail.com>
---
Changes in v4:
- Replace strlcpy() with strscpy() based on maintainer feedback
- Added explanation about user-controlled buffers
Changes in v3:
- Fix Signed-off-by spacing
- Move changelog below '---'
Changes in v2:
- Fixed indentation issues reported by Greg KH
---
.../greybus/Documentation/firmware/firmware.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/drivers/staging/greybus/Documentation/firmware/firmware.c
index 6f6410878ee6..84b9cf45fc8e 100644
--- a/drivers/staging/greybus/Documentation/firmware/firmware.c
+++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
@@ -63,10 +63,11 @@ static int update_intf_firmware(int fd)
intf_load.major = 0;
intf_load.minor = 0;
- strlcpy(intf_load.firmware_tag, firmware_tag,
- GB_FIRMWARE_U_TAG_MAX_SIZE);
+ /* firmware_tag comes from userspace and may not be NUL terminated.
+ * strscpy() avoids strlen() on src and guarantees NUL termination.
+ */
+ strscpy(intf_load.firmware_tag, firmware_tag,
+ GB_FIRMWARE_U_TAG_MAX_SIZE);
ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
if (ret < 0) {
@@ -103,8 +104,8 @@ static int update_backend_firmware(int fd)
/* Get Backend Firmware Version */
printf("Getting Backend Firmware Version\n");
- strlcpy(backend_fw_info.firmware_tag, firmware_tag,
- GB_FIRMWARE_U_TAG_MAX_SIZE);
+ strscpy(backend_fw_info.firmware_tag, firmware_tag,
+ GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_version:
@@ -132,8 +133,8 @@ static int update_backend_firmware(int fd)
/* Try Backend Firmware Update over Unipro */
printf("Updating Backend Firmware\n");
- strlcpy(backend_update.firmware_tag, firmware_tag,
- GB_FIRMWARE_U_TAG_MAX_SIZE);
+ strscpy(backend_update.firmware_tag, firmware_tag,
+ GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_update:
backend_update.status = 0;
--
2.43.0