usbtuner: fix NPE when unplugging Hauppauge 955Q tuner
Jean Huang [Thu, 2 Mar 2017 23:45:21 +0000 (15:45 -0800)]
Bug 1884094

Change-Id: I96889e205fbaaff42bea337189c7abab3da85335
Signed-off-by: Jean Huang <jeanh@nvidia.com>
Signed-off-by: Patrick Horng <phorng@nvidia.com>
Reviewed-on: http://git-master/r/1316567
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-on: http://git-master/r/1456517
Reviewed-by: Manish Tuteja <mtuteja@nvidia.com>

drivers/media/tuners/si2157.c

index 942ab21..e709dfb 100644 (file)
@@ -390,7 +390,9 @@ static void si2157_stat_work(struct work_struct *work)
        c->strength.stat[0].scale = FE_SCALE_DECIBEL;
        c->strength.stat[0].svalue = ((s8) cmd.args[3]) * 1000;
 
-       schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
+        if (dev->active) {
+               schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
+        }
        return;
 err:
        c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
@@ -451,6 +453,9 @@ static int si2157_remove(struct i2c_client *client)
        struct si2157_dev *dev = i2c_get_clientdata(client);
        struct dvb_frontend *fe = dev->fe;
 
+        dev->active = false;
+        cancel_delayed_work_sync(&dev->stat_work);
+
        memset(&fe->ops.tuner_ops, 0, sizeof(fe->ops.tuner_ops));
        fe->tuner_priv = NULL;
        kfree(dev);