usb: misc: Add Intel USBIO bridge driver
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