From: Dan Carpenter <dan.carpenter@linaro.org>
To: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: misc: Add Intel USBIO bridge driver
Date: Thu, 18 Sep 2025 12:51:15 +0300 [thread overview]
Message-ID: <aMvWE0lD3q86JE4k@stanley.mountain> (raw)
Hello Israel Cepeda,
Commit 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver") from
Sep 11, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/usb/misc/usbio.c:187 usbio_ctrl_msg() warn: 'ret' possible negative type promoted to high
drivers/usb/misc/usbio.c:187 usbio_ctrl_msg() warn: error code type promoted to positive: 'ret'
drivers/usb/misc/usbio.c:189 usbio_ctrl_msg() warn: condition is always false
drivers/usb/misc/usbio.c
180 pipe = usb_rcvctrlpipe(usbio->udev, usbio->ctrl_pipe);
181 cpkt_len = sizeof(*cpkt) + ibuf_len;
182 ret = usb_control_msg(usbio->udev, pipe, 0, request | USB_DIR_IN, 0, 0,
183 cpkt, cpkt_len, USBIO_CTRLXFER_TIMEOUT);
184 dev_dbg(usbio->dev, "control in %d hdr %*phN data %*phN\n", ret,
185 (int)sizeof(*cpkt), cpkt, (int)cpkt->len, cpkt->data);
^^^^^^^^^^^^^^^^^^
Instead of casting, these should use %z or whatever...
186
--> 187 if (ret < sizeof(*cpkt)) {
^^^^^^^^^^^^^^^^^^^
if ret is negative then here it's type promoted to a high positive value.
188 dev_err(usbio->dev, "USB control in failed: %d\n", ret);
189 return (ret < 0) ? ret : -EPROTO;
^^^^^^^
impossible.
190 }
191
192 if (cpkt->header.type != type || cpkt->header.cmd != cmd ||
193 !(cpkt->header.flags & USBIO_PKTFLAG_RSP)) {
194 dev_err(usbio->dev, "Unexpected reply type: %u, cmd: %u, flags: %u\n",
195 cpkt->header.type, cpkt->header.cmd, cpkt->header.flags);
196 return -EPROTO;
197 }
198
199 if (cpkt->header.flags & USBIO_PKTFLAG_ERR)
200 return -EREMOTEIO;
201
202 if (ibuf_len < cpkt->len)
203 return -ENOSPC;
204
205 memcpy(ibuf, cpkt->data, cpkt->len);
206
207 return cpkt->len;
208 }
regards,
dan carpenter
reply other threads:[~2025-09-18 9:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aMvWE0lD3q86JE4k@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=israel.a.cepeda.lopez@intel.com \
--cc=linux-usb@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