* [PATCH] gpio: mockup: fix debugfs read
@ 2019-03-22 17:30 Bartosz Golaszewski
2019-03-28 16:37 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-03-22 17:30 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
The debugfs read callback must advance ppos or users using read() on
the file descriptor will never get the EOL. This wasn't spotted before
as I was using busybox cat for testing which uses sendfile() internally
and only noticed it now when switched to cat from coreutils.
Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/gpio/gpio-mockup.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 154d959e8993..74ba8b1d71d8 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -204,8 +204,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
struct gpio_mockup_chip *chip;
struct seq_file *sfile;
struct gpio_chip *gc;
+ int val, rv, cnt;
char buf[3];
- int val, rv;
+
if (*ppos != 0)
return 0;
@@ -216,13 +217,14 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
gc = &chip->gc;
val = gpio_mockup_get(gc, priv->offset);
- snprintf(buf, sizeof(buf), "%d\n", val);
+ cnt = snprintf(buf, sizeof(buf), "%d\n", val);
- rv = copy_to_user(usr_buf, buf, sizeof(buf));
+ rv = copy_to_user(usr_buf, buf, cnt);
if (rv)
return rv;
- return sizeof(buf) - 1;
+ *ppos += cnt;
+ return cnt;
}
static ssize_t gpio_mockup_debugfs_write(struct file *file,
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mockup: fix debugfs read
2019-03-22 17:30 [PATCH] gpio: mockup: fix debugfs read Bartosz Golaszewski
@ 2019-03-28 16:37 ` Linus Walleij
2019-03-28 16:46 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2019-03-28 16:37 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: open list:GPIO SUBSYSTEM, linux-kernel, Bartosz Golaszewski
On Fri, Mar 22, 2019 at 6:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> The debugfs read callback must advance ppos or users using read() on
> the file descriptor will never get the EOL. This wasn't spotted before
> as I was using busybox cat for testing which uses sendfile() internally
> and only noticed it now when switched to cat from coreutils.
>
> Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Patch applied for fixes.
Sorry for slow application, I was in no-wifi-land for some days.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mockup: fix debugfs read
2019-03-28 16:37 ` Linus Walleij
@ 2019-03-28 16:46 ` Bartosz Golaszewski
2019-03-28 16:55 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-03-28 16:46 UTC (permalink / raw)
To: Linus Walleij; +Cc: open list:GPIO SUBSYSTEM, linux-kernel, Bartosz Golaszewski
czw., 28 mar 2019 o 17:38 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> On Fri, Mar 22, 2019 at 6:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > The debugfs read callback must advance ppos or users using read() on
> > the file descriptor will never get the EOL. This wasn't spotted before
> > as I was using busybox cat for testing which uses sendfile() internally
> > and only noticed it now when switched to cat from coreutils.
> >
> > Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Patch applied for fixes.
> Sorry for slow application, I was in no-wifi-land for some days.
>
> Yours,
> Linus Walleij
Ugh, I was thinking about sending you a pull-request with this and a
subsequent fix this evening. Plus other fixes I have in my tree.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mockup: fix debugfs read
2019-03-28 16:46 ` Bartosz Golaszewski
@ 2019-03-28 16:55 ` Linus Walleij
2019-03-28 17:01 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2019-03-28 16:55 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: open list:GPIO SUBSYSTEM, linux-kernel, Bartosz Golaszewski
On Thu, Mar 28, 2019 at 5:47 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> czw., 28 mar 2019 o 17:38 Linus Walleij <linus.walleij@linaro.org> napisał(a):
> > On Fri, Mar 22, 2019 at 6:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > The debugfs read callback must advance ppos or users using read() on
> > > the file descriptor will never get the EOL. This wasn't spotted before
> > > as I was using busybox cat for testing which uses sendfile() internally
> > > and only noticed it now when switched to cat from coreutils.
> > >
> > > Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
> > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Patch applied for fixes.
> > Sorry for slow application, I was in no-wifi-land for some days.
> >
> > Yours,
> > Linus Walleij
>
> Ugh, I was thinking about sending you a pull-request with this and a
> subsequent fix this evening. Plus other fixes I have in my tree.
Oh if it is easier for you do that, and I will drop this patch and just
merge your PR as it arrives.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mockup: fix debugfs read
2019-03-28 16:55 ` Linus Walleij
@ 2019-03-28 17:01 ` Bartosz Golaszewski
0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-03-28 17:01 UTC (permalink / raw)
To: Linus Walleij; +Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, linux-kernel
czw., 28 mar 2019 o 17:56 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> On Thu, Mar 28, 2019 at 5:47 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > czw., 28 mar 2019 o 17:38 Linus Walleij <linus.walleij@linaro.org> napisał(a):
> > > On Fri, Mar 22, 2019 at 6:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > >
> > > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > > >
> > > > The debugfs read callback must advance ppos or users using read() on
> > > > the file descriptor will never get the EOL. This wasn't spotted before
> > > > as I was using busybox cat for testing which uses sendfile() internally
> > > > and only noticed it now when switched to cat from coreutils.
> > > >
> > > > Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface")
> > > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > Patch applied for fixes.
> > > Sorry for slow application, I was in no-wifi-land for some days.
> > >
> > > Yours,
> > > Linus Walleij
> >
> > Ugh, I was thinking about sending you a pull-request with this and a
> > subsequent fix this evening. Plus other fixes I have in my tree.
>
> Oh if it is easier for you do that, and I will drop this patch and just
> merge your PR as it arrives.
>
> Yours,
> Linus Walleij
Yes, let's do it.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-28 17:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 17:30 [PATCH] gpio: mockup: fix debugfs read Bartosz Golaszewski
2019-03-28 16:37 ` Linus Walleij
2019-03-28 16:46 ` Bartosz Golaszewski
2019-03-28 16:55 ` Linus Walleij
2019-03-28 17:01 ` Bartosz Golaszewski
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).