linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Pavel Machek <pavel@denx.de>, "kishon@ti.com" <kishon@ti.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "cip-dev@lists.cip-project.org" <cip-dev@lists.cip-project.org>
Subject: RE: phy-rcar-gen3-usb2: wrong parsing of role in role_store?
Date: Tue, 30 Jul 2019 10:08:33 +0000	[thread overview]
Message-ID: <TYAPR01MB4544F1EE39C3A9F36B13D49AD8DC0@TYAPR01MB4544.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20190730095140.GA29609@amd>

Hi Pavel,

> From: Pavel Machek, Sent: Tuesday, July 30, 2019 6:52 PM
> 
> Hi!
> 
> Code does strcmps, but does not actually check count. So AFAICT
> writing "host-I-don't-want-I-need-peripheral" into the file will
> succeed and turn it into host mode.
> 
> Also data beyond count in buf are going to be accessed.

Thank you for the report. I think the driver should use sysfs_streq() helper
instead of strncmp() on the sysfs function. So, I'll submit such a patch later.

Best regards,
Yoshihiro Shimoda

> Best regards,
> 								Pavel
> 
> static ssize_t role_store(struct device *dev, struct device_attribute *attr,
>                           const char *buf, size_t count)
> {
>         struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
>         bool is_b_device;
>         enum phy_mode cur_mode, new_mode;
> 
>         if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch))
>                 return -EIO;
> 
>         /* FIXME, this is wrong */
>         if (!strncmp(buf, "host", strlen("host")))
>                 new_mode = PHY_MODE_USB_HOST;
>         else if (!strncmp(buf, "peripheral", strlen("peripheral")))
>                 new_mode = PHY_MODE_USB_DEVICE;
>         else
>                 return -EINVAL;
> 
> 
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2019-07-30 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30  9:51 phy-rcar-gen3-usb2: wrong parsing of role in role_store? Pavel Machek
2019-07-30 10:08 ` Yoshihiro Shimoda [this message]
2019-08-01 18:51 ` [cip-dev] " Ben Hutchings

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=TYAPR01MB4544F1EE39C3A9F36B13D49AD8DC0@TYAPR01MB4544.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=pavel@denx.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;
as well as URLs for NNTP newsgroup(s).