V4L/DVB (13547): radio: add trivial checks on the tuner and type args.
[platform/kernel/linux-starfive.git] / drivers / media / radio / radio-maestro.c
index 64d737c..f8213b7 100644 (file)
@@ -200,6 +200,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct maestro *dev = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
                return -EINVAL;
        mutex_lock(&dev->lock);
@@ -213,6 +215,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct maestro *dev = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        mutex_lock(&dev->lock);
        f->frequency = BITS2FREQ(radio_bits_get(dev));