From: Greg KH <gregkh@linuxfoundation.org>
To: GwanYeong Kim <gy741.kim@gmail.com>
Cc: shuah <shuah@kernel.org>,
valentina.manea.m@gmail.com, allison@lohutok.net,
opensource@jilayne.com, changcheng.liu@intel.com,
tglx@linutronix.de, linux-usb@vger.kernel.org
Subject: Re: [PATCH] usbip: tools: Fix read_usb_vudc_device() error path handling
Date: Wed, 16 Oct 2019 06:18:32 -0700 [thread overview]
Message-ID: <20191016131832.GC56859@kroah.com> (raw)
In-Reply-To: <20191016133825.00006e29@gmail.com>
On Wed, Oct 16, 2019 at 01:38:25PM +0900, GwanYeong Kim wrote:
> On Tue, 15 Oct 2019 17:14:32 -0600
> shuah <shuah@kernel.org> wrote:
>
> > On 10/15/19 7:14 AM, GwanYeong Kim wrote:
> > > cannot be less than 0 - fread() returns 0 on error.
> > >
> > > Signed-off-by: GwanYeong Kim <gy741.kim@gmail.com>
> > > ---
> > > tools/usb/usbip/libsrc/usbip_device_driver.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c
> > > b/tools/usb/usbip/libsrc/usbip_device_driver.c index
> > > 051d7d3f443b..49760b98aabc 100644 ---
> > > a/tools/usb/usbip/libsrc/usbip_device_driver.c +++
> > > b/tools/usb/usbip/libsrc/usbip_device_driver.c @@ -79,7 +79,7 @@
> > > int read_usb_vudc_device(struct udev_device *sdev, struct
> > > usbip_usb_device *dev) if (!fd) return -1;
> > > ret = fread((char *) &descr, sizeof(descr), 1, fd);
> > > - if (ret < 0) > + if (ret != sizeof(descr))
> >
> > Are you sure this check is correct? fread() returns the number
> > of elements read, # elements = 1 in this case.
>
> Thank you for pointing this out.
> Sorry for my mistake.
>
> > fread() returns 0 when size or # of elements is 0 and in other
> > error cases it will return < # of elements. I would think you
> > want to check ret != 1 here.
>
> You're right.
> This should be changed to "ret != 1".
>
> Should I send a new patch?
If you want to have it applied, yes.
thanks,
greg k-h
next prev parent reply other threads:[~2019-10-16 13:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 13:14 [PATCH] usbip: tools: Fix read_usb_vudc_device() error path handling GwanYeong Kim
2019-10-15 23:14 ` shuah
2019-10-16 4:38 ` GwanYeong Kim
2019-10-16 13:18 ` Greg KH [this message]
2019-10-17 2:25 ` [PATCH v2] " GwanYeong Kim
2019-10-17 2:33 ` shuah
2019-10-17 5:26 ` GwanYeong Kim
2019-10-17 13:00 ` shuah
2019-10-18 3:22 ` [PATCH v3] " GwanYeong Kim
2019-10-21 18:59 ` shuah
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=20191016131832.GC56859@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=allison@lohutok.net \
--cc=changcheng.liu@intel.com \
--cc=gy741.kim@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=opensource@jilayne.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=valentina.manea.m@gmail.com \
/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).