Skip to content

Commit

Permalink
usb: device_next: uac2: Fix integer handling issues
Browse files Browse the repository at this point in the history
Fix integer handling issues found out by Coverity Scan.

(cherry picked from commit 20983c7)

Original-Coverity-CID: 363729
Original-Coverity-CID: 363737
Original-Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
GitOrigin-RevId: 20983c7
Change-Id: I2205efa208db532a502b3bf4265c27273b591602
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5580447
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Tested-by: Tristan Honscheid <honscheid@google.com>
Commit-Queue: Tristan Honscheid <honscheid@google.com>
  • Loading branch information
tmon-nordic authored and Chromeos LUCI committed May 29, 2024
1 parent 8adbe57 commit ce7945b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion subsys/usb/device_next/class/usbd_uac2.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ get_as_data_ep(struct usbd_class_data *const c_data, int as_idx)
const struct uac2_cfg *cfg = dev->config;
const struct usb_desc_header *desc = NULL;

if ((as_idx < cfg->num_ifaces) && cfg->ep_indexes[as_idx]) {
if ((as_idx >= 0) && (as_idx < cfg->num_ifaces) &&
cfg->ep_indexes[as_idx]) {
desc = cfg->descriptors[cfg->ep_indexes[as_idx]];
}

Expand Down Expand Up @@ -344,6 +345,8 @@ static void write_explicit_feedback(struct usbd_class_data *const c_data,
int as_idx = terminal_to_as_interface(dev, terminal);
int ret;

__ASSERT_NO_MSG(as_idx >= 0);

buf = net_buf_alloc(&uac2_pool, K_NO_WAIT);
if (!buf) {
LOG_ERR("No buf for feedback");
Expand Down

0 comments on commit ce7945b

Please sign in to comment.