Hi,
I'm using sth. like the following code snippet to setup IIO devices and channels:
dev = iio_context_find_device(ctx, "iio-device-name");
err = iio_err(dev);
if (err) shutdown();
ch = iio_device_find_channel(dev, "voltage0", false);
In the normal case this works as expected. To test the error paths in my code, I just unloaded the IIO kernel driver being used and was greated with a null-ptr deref on dev in iio_device_find_channel(). The error could be easily fixed with an explicit NULL check:
if (err || !dev) shutdown();
However, I wondered if iio_err() should handle this case implicitly to reduce the error handling boilerplate for users?
Edit: This was observed on 2c5c1f8.