Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Petar Stepanovic" <pstepanovic@axiado.com>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 4/6] usb: gadget: udc: crg: Add endpoint 0 handling
Date: Fri, 04 Dec 2026 02:03:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-248935@kernel.org> (raw)
In-Reply-To: <20261203-axiado-ax3000-usb-device-controller-v8-4-d5ff04febd4d@axiado.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] usb: gadget: crg: setfeaturesrequest() accepts reserved test
  mode selector 6
- [Low] usb: gadget: crg: unused-but-set variable sel in setselrequest()
--

commit 6c30ff6815aed356c055827a163e2d8f4ed0589e
Author: Petar Stepanovic <pstepanovic@axiado.com>

usb: gadget: udc: crg: Add endpoint 0 handling

This patch adds endpoint 0 setup packet, status stage, and control
transfer handling for the Axiado AX3000/AX3005 UDC driver.

> diff --git a/drivers/usb/gadget/udc/crg/crg-udc-ep0.c b/drivers/usb/gadget/udc/crg/crg-udc-ep0.c
> new file mode 100644
> index 0000000000000..dbc9780050c71
> --- /dev/null
> +++ b/drivers/usb/gadget/udc/crg/crg-udc-ep0.c
> @@ -0,0 +1,1270 @@

[ ... ]

> +		case USB_DEVICE_TEST_MODE: {
> +			u32 u_pattern;
> +
> +			if (b_request != USB_REQ_SET_FEATURE ||
> +			    crg_udc->gadget.speed != USB_SPEED_HIGH ||
> +			    crg_udc->device_state < USB_STATE_DEFAULT ||
> +			    (index & 0xff) || (index >> 8) == 0 ||
> +			    (index >> 8) > 6)
> +				goto set_feature_error;
> +			u_pattern = index >> 8;
> +			crg_udc->set_tm = u_pattern;
> +			crg_udc->setup_fn_call_back = &set_test_mode_cmpl;

[Severity: Low]
Should this upper bound be USB_TEST_FORCE_ENABLE (5) rather than 6?

Standard USB 2.0 test mode selectors in include/uapi/linux/usb/ch9.h run
from USB_TEST_J (1) through USB_TEST_FORCE_ENABLE (5), while selector 6
is reserved.  Accepting wIndex 0x0600 lets set_test_mode_cmpl() write
the reserved value 6 into uccr->u2portpmsc instead of stalling EP0.

[ ... ]

> +static void setselrequest(struct crg_gadget_dev *crg_udc, u16 value, u16 index,
> +			  u16 length)
> +{
> +	struct crg_udc_request *udc_req_ptr = crg_udc->status_req;
> +	struct crg_udc_ep *udc_ep_ptr = &crg_udc->udc_ep[0];
> +	struct usb_set_sel_req *sel;
> +	int ret;
> +
> +	if (!udc_req_ptr || crg_udc->status_req_callback_pending ||
> +	    !list_empty(&udc_req_ptr->queue) ||
> +	    crg_udc->device_state == USB_STATE_DEFAULT || value || index ||
> +	    length != sizeof(struct usb_set_sel_req)) {
> +		crg_udc_set_ep0_halt(crg_udc);
> +		return;
> +	}
> +
> +	kfree(udc_req_ptr->usb_req.buf);
> +
> +	udc_req_ptr->usb_req.buf = kzalloc_obj(*sel, GFP_ATOMIC);
> +	if (!udc_req_ptr->usb_req.buf) {
> +		crg_udc_set_ep0_halt(crg_udc);
> +		return;
> +	}
> +
> +	sel = udc_req_ptr->usb_req.buf;
> +	udc_req_ptr->usb_req.length = sizeof(*sel);

[Severity: Low]
Will assigning sel here trigger a -Wunused-but-set-variable warning under
W=1 builds?

sel is never read because kzalloc_obj(*sel, GFP_ATOMIC) and sizeof(*sel)
only inspect its type, so this breaks W=1 builds with CONFIG_WERROR=y.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-axiado-ax3000-usb-device-controller-v8-0-d5ff04febd4d@axiado.com?part=4

  reply	other threads:[~2026-12-04  2:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  1:31 [PATCH v8 0/6] Axiado AX3000 and AX3005 USB Device Controller (UDC) Petar Stepanovic
2026-12-04  1:31 ` [PATCH v8 1/6] dt-bindings: usb: gadget: udc: add Axiado AX3000 and AX3005 UDC Petar Stepanovic
2026-12-04  1:31 ` [PATCH v8 2/6] usb: gadget: udc: crg: Add hardware definitions and structs Petar Stepanovic
2026-12-04  1:53   ` sashiko-bot
2026-12-04  1:31 ` [PATCH v8 3/6] usb: gadget: udc: crg: Add ring and transfer management Petar Stepanovic
2026-12-04  1:53   ` sashiko-bot
2026-12-04  1:31 ` [PATCH v8 4/6] usb: gadget: udc: crg: Add endpoint 0 handling Petar Stepanovic
2026-12-04  2:03   ` sashiko-bot [this message]
2026-12-04  1:31 ` [PATCH v8 5/6] usb: gadget: udc: crg: Add gadget and endpoint operations Petar Stepanovic
2026-12-04  2:03   ` sashiko-bot
2026-12-04  1:31 ` [PATCH v8 6/6] usb: gadget: udc: crg: Add core driver and build integration Petar Stepanovic
2026-12-04  2:07   ` sashiko-bot
2026-12-04  2:07 ` [PATCH v8 0/6] Axiado AX3000 and AX3005 USB Device Controller (UDC) sashiko-bot

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=sashiko-outbox-248935@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pstepanovic@axiado.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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