* [PATCH] staging: fbtft: check return value of device_create_file()
@ 2026-05-11 10:01 Harshit Shaw
2026-05-11 10:08 ` Greg KH
2026-05-11 11:46 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Harshit Shaw @ 2026-05-11 10:01 UTC (permalink / raw)
To: deller
Cc: tzimmermann, chintanlike, andriy.shevchenko, gregkh,
linux-staging, linux-kernel, Harshit Shaw
device_create_file() can fail but its return value was being
ignored in fbtft_sysfs_init(). Check the return value and
emit a warning if sysfs file creation fails.
Signed-off-by: Harshit Shaw <shawharshit116@gmail.com>
---
drivers/staging/fbtft/fbtft-sysfs.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
index d05599d80011..cc6dbaeb6043 100644
--- a/drivers/staging/fbtft/fbtft-sysfs.c
+++ b/drivers/staging/fbtft/fbtft-sysfs.c
@@ -204,14 +204,21 @@ static struct device_attribute debug_device_attr =
void fbtft_sysfs_init(struct fbtft_par *par)
{
struct device *dev;
+ int ret;
dev = dev_of_fbinfo(par->info);
if (!dev)
return;
- device_create_file(dev, &debug_device_attr);
- if (par->gamma.curves && par->fbtftops.set_gamma)
- device_create_file(dev, &gamma_device_attrs[0]);
+ ret = device_create_file(dev, &debug_device_attr);
+ if (ret)
+ dev_warn(dev, "failed to create debug sysfs entry\n");
+
+ if (par->gamma.curves && par->fbtftops.set_gamma) {
+ ret = device_create_file(dev, &gamma_device_attrs[0]);
+ if (ret)
+ dev_warn(dev, "failed to create gamma sysfs entry\n");
+ }
}
void fbtft_sysfs_exit(struct fbtft_par *par)
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: fbtft: check return value of device_create_file()
2026-05-11 10:01 [PATCH] staging: fbtft: check return value of device_create_file() Harshit Shaw
@ 2026-05-11 10:08 ` Greg KH
2026-05-11 11:46 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-05-11 10:08 UTC (permalink / raw)
To: Harshit Shaw
Cc: deller, tzimmermann, chintanlike, andriy.shevchenko,
linux-staging, linux-kernel
On Mon, May 11, 2026 at 10:01:40AM +0000, Harshit Shaw wrote:
> device_create_file() can fail but its return value was being
> ignored in fbtft_sysfs_init(). Check the return value and
> emit a warning if sysfs file creation fails.
>
> Signed-off-by: Harshit Shaw <shawharshit116@gmail.com>
> ---
> drivers/staging/fbtft/fbtft-sysfs.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
> index d05599d80011..cc6dbaeb6043 100644
> --- a/drivers/staging/fbtft/fbtft-sysfs.c
> +++ b/drivers/staging/fbtft/fbtft-sysfs.c
> @@ -204,14 +204,21 @@ static struct device_attribute debug_device_attr =
> void fbtft_sysfs_init(struct fbtft_par *par)
> {
> struct device *dev;
> + int ret;
>
> dev = dev_of_fbinfo(par->info);
> if (!dev)
> return;
>
> - device_create_file(dev, &debug_device_attr);
> - if (par->gamma.curves && par->fbtftops.set_gamma)
> - device_create_file(dev, &gamma_device_attrs[0]);
> + ret = device_create_file(dev, &debug_device_attr);
> + if (ret)
> + dev_warn(dev, "failed to create debug sysfs entry\n");
This sysfs file should not be there at all, can you work to remove it
and just use the "normal" debug api for logging stuff?
Also, no driver should be calling this function directly, a default
attribute group is the correct solution. So don't paper over this
warning by just checking the error value now, do the right thing
instead.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: fbtft: check return value of device_create_file()
2026-05-11 10:01 [PATCH] staging: fbtft: check return value of device_create_file() Harshit Shaw
2026-05-11 10:08 ` Greg KH
@ 2026-05-11 11:46 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-05-11 11:46 UTC (permalink / raw)
To: Harshit Shaw
Cc: deller, tzimmermann, chintanlike, andriy.shevchenko, gregkh,
linux-staging, linux-kernel
On Mon, May 11, 2026 at 10:01:40AM +0000, Harshit Shaw wrote:
> device_create_file() can fail but its return value was being
> ignored in fbtft_sysfs_init(). Check the return value and
> emit a warning if sysfs file creation fails.
>
> Signed-off-by: Harshit Shaw <shawharshit116@gmail.com>
> ---
What's the point of this though? How is your warning message more
informative than the warning messages printed out by
device_create_file()?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 11:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 10:01 [PATCH] staging: fbtft: check return value of device_create_file() Harshit Shaw
2026-05-11 10:08 ` Greg KH
2026-05-11 11:46 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox