[PATCH] staging: fbtft: check return value of device_create_file()

From: Harshit Shaw

Date: Mon May 11 2026 - 06:05:09 EST


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@xxxxxxxxx>
---
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