From: Greg KH <gregkh@linuxfoundation.org>
To: Keshav Verma <iganschel@gmail.com>
Cc: johan@kernel.org, kees@kernel.org, o.bock@fh-wolfenbuettel.de,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: misc: cypress_cy7c63: check control transfer status
Date: Wed, 8 Jul 2026 17:15:39 +0200 [thread overview]
Message-ID: <2026070835-thorn-doable-8c28@gregkh> (raw)
In-Reply-To: <20260618203053.4725-1-iganschel@gmail.com>
On Fri, Jun 19, 2026 at 02:00:53AM +0530, Keshav Verma wrote:
> read_port() currently ignores errors from vendor_command() and always
> returns the cached port value. This can report stale data when the USB
> control transfer fails or returns a short response.
>
> Return the underlying error for failed transfers and report -EIO if the
> device returns fewer bytes than required.
>
> Fixes: 9189bfc2df0f ("[PATCH] USB: rename Cypress CY7C63xxx driver to proper name and fix up some tiny things")
> Signed-off-by: Keshav Verma <iganschel@gmail.com>
> ---
> drivers/usb/misc/cypress_cy7c63.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
> index 4a7f955ba85b..8601ee0a1ea3 100644
> --- a/drivers/usb/misc/cypress_cy7c63.c
> +++ b/drivers/usb/misc/cypress_cy7c63.c
> @@ -177,6 +177,10 @@ static ssize_t read_port(struct device *dev, struct device_attribute *attr,
> result = vendor_command(cyp, CYPRESS_READ_PORT, read_id, 0);
>
> dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n", result);
> + if (result < 0)
> + return result;
> + if (result < 2)
> + return -EIO;
>
> return sprintf(buf, "%d", cyp->port[port_num]);
> }
You only changed one call to vendor_command() here, why? Why not fix
this all up by changing vendor_command() to use a better function that
will give you a sane error value, and then check that?
Start with this patch:
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index d26f460ecdbc..86c4678e23b3 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -51,12 +51,10 @@ static int vendor_command(struct usb_device *dev, unsigned char request,
unsigned char value, unsigned char index,
void *buf, int size)
{
- return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
- request,
- USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
- value,
- index, buf, size,
- USB_CTRL_GET_TIMEOUT);
+ return usb_control_msg_recv(dev, 0, request,
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
+ value, index, buf, size,
+ USB_CTRL_GET_TIMEOUT, GFP_KERNEL);
}
And go from there!
thanks,
greg k-h
next prev parent reply other threads:[~2026-07-08 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 20:30 [PATCH] usb: misc: cypress_cy7c63: check control transfer status Keshav Verma
2026-07-08 15:15 ` Greg KH [this message]
2026-07-08 18:04 ` Keshav Verma
2026-07-09 23:30 ` Keshav Verma
2026-07-10 9:53 ` Oliver Neukum
2026-07-10 12:01 ` Keshav Verma
2026-07-10 12:06 ` Greg KH
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=2026070835-thorn-doable-8c28@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=iganschel@gmail.com \
--cc=johan@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=o.bock@fh-wolfenbuettel.de \
/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