Skip to content

Commit 0f63d65

Browse files
mhennerichgastmaier
authored andcommitted
iio: adc: ad9081: Validate sysfs_emit() result in ext_info_read()
Ensure the return value of sysfs_emit() is properly checked in ad9081_ext_info_read() to catch cases where no data is written or an error occurs. This prevents misleading success returns when the buffer emission fails. Set ret = -EINVAL if sysfs_emit() returns zero or a negative value, aligning with expected error handling practices in sysfs attribute reads. Signed-off-by: Michael Hennerich <[email protected]> (cherry picked from commit ba297cc)
1 parent eb889ed commit 0f63d65

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/iio/adc/ad9081.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,8 @@ static ssize_t ad9081_ext_info_read(struct iio_dev *indio_dev,
13341334
}
13351335
ret = sysfs_emit(buf, "%lld\n",
13361336
phy->tx_ffh_hopf_vals[phy->tx_ffh_hopf_index[cddc_num]][cddc_num]);
1337+
if (ret <= 0)
1338+
ret = -EINVAL;
13371339
break;
13381340
default:
13391341
ret = -EINVAL;

0 commit comments

Comments
 (0)