diff options
author | Stefan Agner <stefan.agner@toradex.com> | 2014-01-22 18:41:04 +0100 |
---|---|---|
committer | Stefan Agner <stefan.agner@toradex.com> | 2014-01-22 18:48:19 +0100 |
commit | 139f77a7efd40d2eb2a4a8b2d8041b80dd3965b8 (patch) | |
tree | 125e88e64aa6f6ab96cbcbad0a206c081c6458b5 /drivers | |
parent | 1d3625dd9903bcc59e2df56836565ebb682948c1 (diff) |
Check null pointers for sysfs calls
When grepping through sysfs, grep tries to read all sysfs files
which are available. Some of them lead to error due to null pointers.
Therefor check for null pointers before using them.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/industrialio-core.c | 10 | ||||
-rw-r--r-- | drivers/video/tegra/fb.c | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 19819e7578c6..fd812c343e81 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -860,7 +860,10 @@ static ssize_t iio_ev_state_show(struct device *dev, { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int val = indio_dev->info->read_event_config(indio_dev, + int val = -ENODEV; + + if (indio_dev->info != NULL && indio_dev->info->read_event_config != NULL) + val = indio_dev->info->read_event_config(indio_dev, this_attr->address); if (val < 0) @@ -875,9 +878,10 @@ static ssize_t iio_ev_value_show(struct device *dev, { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int val, ret; + int val, ret = -ENODEV; - ret = indio_dev->info->read_event_value(indio_dev, + if (indio_dev->info != NULL && indio_dev->info->read_event_config != NULL) + ret = indio_dev->info->read_event_value(indio_dev, this_attr->address, &val); if (ret < 0) return ret; diff --git a/drivers/video/tegra/fb.c b/drivers/video/tegra/fb.c index 70b82bde9e43..b687382d1dd4 100644 --- a/drivers/video/tegra/fb.c +++ b/drivers/video/tegra/fb.c @@ -399,6 +399,9 @@ static int tegra_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long } int tegra_fb_get_mode(struct tegra_dc *dc) { + /* Avoid error when reading sysfs */ + if (dc->fb->info->mode == NULL) + return 0; return dc->fb->info->mode->refresh; } |