* [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute
@ 2017-08-16 15:39 Michael Tretter
2017-08-17 9:59 ` Jani Nikula
0 siblings, 1 reply; 7+ messages in thread
From: Michael Tretter @ 2017-08-16 15:39 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter, Michael Tretter, kernel
Using plain echo to set the "force" connector attribute fails with
-EINVAL, because echo appends a newline to the output.
Strip trailing whitespace in the input before checking the value to
accept "off\n" or "off ".
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
drivers/gpu/drm/drm_debugfs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index c1807d5754b2..10dd89d3f28e 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -241,6 +241,7 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
struct seq_file *m = file->private_data;
struct drm_connector *connector = m->private;
char buf[12];
+ int i;
if (len > sizeof(buf) - 1)
return -EINVAL;
@@ -250,6 +251,10 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
buf[len] = '\0';
+ /* strip trailing whitespace */
+ for (i = len - 1; i > 0 && isspace(buf[i]); i--)
+ buf[i] = '\0';
+
if (!strcmp(buf, "on"))
connector->force = DRM_FORCE_ON;
else if (!strcmp(buf, "digital"))
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute
2017-08-16 15:39 [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute Michael Tretter
@ 2017-08-17 9:59 ` Jani Nikula
2017-08-17 10:43 ` [PATCH v2] drm/debugfs: fix plain echo to connector " Michael Tretter
0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2017-08-17 9:59 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter, Michael Tretter, kernel
On Wed, 16 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> Using plain echo to set the "force" connector attribute fails with
> -EINVAL, because echo appends a newline to the output.
>
> Strip trailing whitespace in the input before checking the value to
> accept "off\n" or "off ".
Please replace the strcmp() calls with sysfs_streq() instead.
BR,
Jani.
>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> drivers/gpu/drm/drm_debugfs.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index c1807d5754b2..10dd89d3f28e 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -241,6 +241,7 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
> struct seq_file *m = file->private_data;
> struct drm_connector *connector = m->private;
> char buf[12];
> + int i;
>
> if (len > sizeof(buf) - 1)
> return -EINVAL;
> @@ -250,6 +251,10 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
>
> buf[len] = '\0';
>
> + /* strip trailing whitespace */
> + for (i = len - 1; i > 0 && isspace(buf[i]); i--)
> + buf[i] = '\0';
> +
> if (!strcmp(buf, "on"))
> connector->force = DRM_FORCE_ON;
> else if (!strcmp(buf, "digital"))
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] drm/debugfs: fix plain echo to connector "force" attribute
2017-08-17 9:59 ` Jani Nikula
@ 2017-08-17 10:43 ` Michael Tretter
2017-08-17 11:39 ` Jani Nikula
0 siblings, 1 reply; 7+ messages in thread
From: Michael Tretter @ 2017-08-17 10:43 UTC (permalink / raw)
To: Jani Nikula, dri-devel; +Cc: Daniel Vetter, Michael Tretter, kernel
Using plain echo to set the "force" connector attribute fails with
-EINVAL, because echo appends a newline to the output.
Replace strcmp with sysfs_streq to also accept strings that end with a
newline.
v2: use sysfs_streq instead of stripping trailing whitespace
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
drivers/gpu/drm/drm_debugfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index c1807d5754b2..454deba13ee5 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -250,13 +250,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
buf[len] = '\0';
- if (!strcmp(buf, "on"))
+ if (sysfs_streq(buf, "on"))
connector->force = DRM_FORCE_ON;
- else if (!strcmp(buf, "digital"))
+ else if (sysfs_streq(buf, "digital"))
connector->force = DRM_FORCE_ON_DIGITAL;
- else if (!strcmp(buf, "off"))
+ else if (sysfs_streq(buf, "off"))
connector->force = DRM_FORCE_OFF;
- else if (!strcmp(buf, "unspecified"))
+ else if (sysfs_streq(buf, "unspecified"))
connector->force = DRM_FORCE_UNSPECIFIED;
else
return -EINVAL;
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/debugfs: fix plain echo to connector "force" attribute
2017-08-17 10:43 ` [PATCH v2] drm/debugfs: fix plain echo to connector " Michael Tretter
@ 2017-08-17 11:39 ` Jani Nikula
2020-05-17 20:49 ` Emil Velikov
0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2017-08-17 11:39 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter, Michael Tretter, kernel
On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> Using plain echo to set the "force" connector attribute fails with
> -EINVAL, because echo appends a newline to the output.
>
> Replace strcmp with sysfs_streq to also accept strings that end with a
> newline.
>
> v2: use sysfs_streq instead of stripping trailing whitespace
>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/drm_debugfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index c1807d5754b2..454deba13ee5 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -250,13 +250,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
>
> buf[len] = '\0';
>
> - if (!strcmp(buf, "on"))
> + if (sysfs_streq(buf, "on"))
> connector->force = DRM_FORCE_ON;
> - else if (!strcmp(buf, "digital"))
> + else if (sysfs_streq(buf, "digital"))
> connector->force = DRM_FORCE_ON_DIGITAL;
> - else if (!strcmp(buf, "off"))
> + else if (sysfs_streq(buf, "off"))
> connector->force = DRM_FORCE_OFF;
> - else if (!strcmp(buf, "unspecified"))
> + else if (sysfs_streq(buf, "unspecified"))
> connector->force = DRM_FORCE_UNSPECIFIED;
> else
> return -EINVAL;
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/debugfs: fix plain echo to connector "force" attribute
2017-08-17 11:39 ` Jani Nikula
@ 2020-05-17 20:49 ` Emil Velikov
2020-05-18 9:22 ` Jani Nikula
0 siblings, 1 reply; 7+ messages in thread
From: Emil Velikov @ 2020-05-17 20:49 UTC (permalink / raw)
To: Jani Nikula; +Cc: Sascha Hauer, Daniel Vetter, Michael Tretter, ML dri-devel
On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> > Using plain echo to set the "force" connector attribute fails with
> > -EINVAL, because echo appends a newline to the output.
> >
> > Replace strcmp with sysfs_streq to also accept strings that end with a
> > newline.
> >
> > v2: use sysfs_streq instead of stripping trailing whitespace
> >
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
Seems like this fell through the cracks. Pushed to drm-misc-next.
Thanks
Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/debugfs: fix plain echo to connector "force" attribute
2020-05-17 20:49 ` Emil Velikov
@ 2020-05-18 9:22 ` Jani Nikula
2020-05-18 10:39 ` Emil Velikov
0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2020-05-18 9:22 UTC (permalink / raw)
To: Emil Velikov; +Cc: Sascha Hauer, Daniel Vetter, Michael Tretter, ML dri-devel
On Sun, 17 May 2020, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>>
>> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
>> > Using plain echo to set the "force" connector attribute fails with
>> > -EINVAL, because echo appends a newline to the output.
>> >
>> > Replace strcmp with sysfs_streq to also accept strings that end with a
>> > newline.
>> >
>> > v2: use sysfs_streq instead of stripping trailing whitespace
>> >
>> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
>>
>> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>>
> Seems like this fell through the cracks. Pushed to drm-misc-next.
From 2017? How'd you find it? :o
My bad, thanks.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/debugfs: fix plain echo to connector "force" attribute
2020-05-18 9:22 ` Jani Nikula
@ 2020-05-18 10:39 ` Emil Velikov
0 siblings, 0 replies; 7+ messages in thread
From: Emil Velikov @ 2020-05-18 10:39 UTC (permalink / raw)
To: Jani Nikula; +Cc: Sascha Hauer, Daniel Vetter, Michael Tretter, ML dri-devel
On Mon, 18 May 2020 at 10:22, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> On Sun, 17 May 2020, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> > On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> >>
> >> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> >> > Using plain echo to set the "force" connector attribute fails with
> >> > -EINVAL, because echo appends a newline to the output.
> >> >
> >> > Replace strcmp with sysfs_streq to also accept strings that end with a
> >> > newline.
> >> >
> >> > v2: use sysfs_streq instead of stripping trailing whitespace
> >> >
> >> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> >>
> >> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> >>
> > Seems like this fell through the cracks. Pushed to drm-misc-next.
>
> From 2017? How'd you find it? :o
>
> My bad, thanks.
>
A colleague mentioned about their experiences with \n, so I remembered
seeing something.
From a quick grep, we have have handful of other cases mostly in
amdgpu and radeon. Will see it I can prep a patch later on today.
-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-05-18 10:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16 15:39 [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute Michael Tretter
2017-08-17 9:59 ` Jani Nikula
2017-08-17 10:43 ` [PATCH v2] drm/debugfs: fix plain echo to connector " Michael Tretter
2017-08-17 11:39 ` Jani Nikula
2020-05-17 20:49 ` Emil Velikov
2020-05-18 9:22 ` Jani Nikula
2020-05-18 10:39 ` Emil Velikov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.