diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-11-02 00:05:44 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-11 21:04:51 +0300 |
commit | 02d7324337c0223f3775d539380e32f603646a52 (patch) | |
tree | 2579709a778712acb375ef4863dd19b6606a7bf7 /drivers/media/radio | |
parent | bc3cad2b9261de7a5fa7632d30271e6d8418cb8f (diff) | |
download | linux-02d7324337c0223f3775d539380e32f603646a52.tar.xz |
media: radio-si476x: fix behavior when seek->range* are defined
The logic at si476x_radio_s_hw_freq_seek() checks if the
frequency range that will be used to handle hardware seek
has the minimal frequency under rangelow. That works fine
if userspace zeros both fields. However, if userspace
fills either seek->rangelow or seek-rangehigh, it won't
read the corresponding range from the device, causing the
values to be unitialized, as warned by smatch:
drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangelow'.
drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangehigh'.
Fix it by initializing those vars from the values present at
the struct v4l2_hw_freq_seek.
While here, simplify the logic which reads such values from
the hardware limits.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/radio-si476x.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c index 540ac887a63c..d1355ac2df2f 100644 --- a/drivers/media/radio/radio-si476x.c +++ b/drivers/media/radio/radio-si476x.c @@ -759,7 +759,7 @@ static int si476x_radio_s_hw_freq_seek(struct file *file, void *priv, { int err; enum si476x_func func; - u32 rangelow, rangehigh; + u32 rangelow = seek->rangelow, rangehigh = seek->rangehigh; struct si476x_radio *radio = video_drvdata(file); if (file->f_flags & O_NONBLOCK) @@ -771,23 +771,21 @@ static int si476x_radio_s_hw_freq_seek(struct file *file, void *priv, si476x_core_lock(radio->core); - if (!seek->rangelow) { + if (!rangelow) { err = regmap_read(radio->core->regmap, SI476X_PROP_SEEK_BAND_BOTTOM, &rangelow); - if (!err) - rangelow = si476x_to_v4l2(radio->core, rangelow); - else + if (err) goto unlock; + rangelow = si476x_to_v4l2(radio->core, rangelow); } - if (!seek->rangehigh) { + if (!rangehigh) { err = regmap_read(radio->core->regmap, SI476X_PROP_SEEK_BAND_TOP, &rangehigh); - if (!err) - rangehigh = si476x_to_v4l2(radio->core, rangehigh); - else + if (err) goto unlock; + rangehigh = si476x_to_v4l2(radio->core, rangehigh); } if (rangelow > rangehigh) { |