All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: fieldbus: Use sysfs_emit for show(device *...) functions
@ 2020-10-18 18:26 Deepak R Varma
  2020-10-23 13:40 ` Sven Van Asbroeck
  0 siblings, 1 reply; 3+ messages in thread
From: Deepak R Varma @ 2020-10-18 18:26 UTC (permalink / raw)
  To: outreachy-kernel, Sven Van Asbroeck, Greg Kroah-Hartman; +Cc: mh12gx2825

Convert snprintf calls in device show functions to sysfs_emit for
PAGE_SIZE buffer safety.
Warning generated by: scripts/coccinelle/api/device_attr_show.cocci

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
---
 drivers/staging/fieldbus/dev_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
index 1ba0234cc60d..698d7b479270 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
 	 * card_name was provided by child driver, could potentially be long.
 	 * protect against buffer overrun.
 	 */
-	return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
+	return sysfs_emit(buf, "%s\n", fb->card_name);
 }
 static DEVICE_ATTR_RO(card_name);
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: fieldbus: Use sysfs_emit for show(device *...) functions
  2020-10-18 18:26 [PATCH] staging: fieldbus: Use sysfs_emit for show(device *...) functions Deepak R Varma
@ 2020-10-23 13:40 ` Sven Van Asbroeck
  2020-11-02 20:28   ` Deepak R Varma
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Van Asbroeck @ 2020-10-23 13:40 UTC (permalink / raw)
  To: Deepak R Varma; +Cc: outreachy-kernel, Greg Kroah-Hartman

Hi Deepak, thank you for the patch.

There are many other sysfs show functions in this driver that can be converted
to use sysfs_emit().

But, the perfect musn't be the enemy of the good:

Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>

On Sun, Oct 18, 2020 at 2:26 PM Deepak R Varma <mh12gx2825@gmail.com> wrote:
>
> Convert snprintf calls in device show functions to sysfs_emit for
> PAGE_SIZE buffer safety.
> Warning generated by: scripts/coccinelle/api/device_attr_show.cocci
>
> Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
> ---
>  drivers/staging/fieldbus/dev_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
> index 1ba0234cc60d..698d7b479270 100644
> --- a/drivers/staging/fieldbus/dev_core.c
> +++ b/drivers/staging/fieldbus/dev_core.c
> @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
>          * card_name was provided by child driver, could potentially be long.
>          * protect against buffer overrun.
>          */
> -       return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
> +       return sysfs_emit(buf, "%s\n", fb->card_name);
>  }
>  static DEVICE_ATTR_RO(card_name);
>
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: fieldbus: Use sysfs_emit for show(device *...) functions
  2020-10-23 13:40 ` Sven Van Asbroeck
@ 2020-11-02 20:28   ` Deepak R Varma
  0 siblings, 0 replies; 3+ messages in thread
From: Deepak R Varma @ 2020-11-02 20:28 UTC (permalink / raw)
  To: Sven Van Asbroeck; +Cc: outreachy-kernel, Greg Kroah-Hartman

On Fri, Oct 23, 2020 at 09:40:25AM -0400, Sven Van Asbroeck wrote:
> Hi Deepak, thank you for the patch.
> 
> There are many other sysfs show functions in this driver that can be converted
> to use sysfs_emit().

Hello Sven & Greg,
Is it okay for me to now change other show functions as suggested for 
this driver and send another patch?
Just want to confirm since I will be sending the patches from the linux
next tree and for the staging driver.

Thank you.
./drv


> 
> But, the perfect musn't be the enemy of the good:
> 
> Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
> 
> On Sun, Oct 18, 2020 at 2:26 PM Deepak R Varma <mh12gx2825@gmail.com> wrote:
> >
> > Convert snprintf calls in device show functions to sysfs_emit for
> > PAGE_SIZE buffer safety.
> > Warning generated by: scripts/coccinelle/api/device_attr_show.cocci
> >
> > Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
> > ---
> >  drivers/staging/fieldbus/dev_core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
> > index 1ba0234cc60d..698d7b479270 100644
> > --- a/drivers/staging/fieldbus/dev_core.c
> > +++ b/drivers/staging/fieldbus/dev_core.c
> > @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
> >          * card_name was provided by child driver, could potentially be long.
> >          * protect against buffer overrun.
> >          */
> > -       return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
> > +       return sysfs_emit(buf, "%s\n", fb->card_name);
> >  }
> >  static DEVICE_ATTR_RO(card_name);
> >
> > --
> > 2.25.1
> >


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-02 20:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-18 18:26 [PATCH] staging: fieldbus: Use sysfs_emit for show(device *...) functions Deepak R Varma
2020-10-23 13:40 ` Sven Van Asbroeck
2020-11-02 20:28   ` Deepak R Varma

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.