iio: frequency: adf4350: using an uninitialized variable
Subsystems (3)
PATCH 1/2 iio: frequency: adf4350: using an uninitialized variable
GCC complains that we use an uninitialized variable if the user passes an invalid parameter to adf4350_read(). I decided that we should return -EINVAL instead in that case.
However, when I looked up at adf4350_write() it returned -ENODEV for that condition. In the end, I decided the -EINVAL was the right thing and I change adf4350_write() to match.
drivers/iio/frequency/adf4350.c +3 -1
@@ -272,7 +272,7 @@ static ssize_t adf4350_write(struct iio_dev *indio_dev,adf4350_sync_config (st);break ;default : - ret = -ENODEV ; + ret = -EINVAL ; }mutex_unlock (&indio_dev->mlock);
@@ -310,6 +310,8 @@ static ssize_t adf4350_read(struct iio_dev *indio_dev,case ADF4350_PWRDOWN : val = !!(st->regs[ADF4350_REG2 ] &ADF4350_REG2_POWER_DOWN_EN );break ; +default : + ret = -EINVAL ; }mutex_unlock (&indio_dev->mlock);
Quoted 7 lines · Dan Carpenter
GCC complains that we use an uninitialized variable if the user passes an invalid parameter to
adf4350_read(). I decided that we should return-EINVALinstead in that case.However, when I looked up at
adf4350_write()it returned-ENODEVfor that condition. In the end, I decided the-EINVALwas the right thing and I changeadf4350_write()to match.
Agreed.
Quoted 2 lines
Signed-off-by Dan Carpenter<[email protected]>
Quoted 24 lines
drivers/iio/frequency/adf4350.c +3
-1@@ -272,7 +272,7 @@ static ssize_t adf4350_write(struct iio_dev *indio_dev,adf4350_sync_config (st);break ;default : - ret = -ENODEV ; + ret = -EINVAL ; }mutex_unlock (&indio_dev->mlock);@@ -310,6 +310,8 @@ static ssize_t adf4350_read(struct iio_dev *indio_dev,case ADF4350_PWRDOWN : val = !!(st->regs[ADF4350_REG2 ]&ADF4350_REG2_POWER_DOWN_EN );break ; +default : + ret = -EINVAL ; }mutex_unlock (&indio_dev->mlock);
Signature · 8 lines
Greetings, Michael -- Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif