]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
misc: nct1008: fix NULL ptr access in get_trend
authorSrikar Srimath Tirumala <srikars@nvidia.com>
Wed, 24 May 2017 02:10:07 +0000 (19:10 -0700)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 7 Jun 2017 11:00:16 +0000 (04:00 -0700)
Return a stable trend when trend is queried during boot before
all the pointers are initialized.

Bug 200311672

Change-Id: I6b03b266b868ac1bd6e39ea63078d24e273bc327
Signed-off-by: Srikar Srimath Tirumala <srikars@nvidia.com>
Reviewed-on: http://git-master/r/1488401
(cherry picked from commit f507b9b74fede1e1adac02c295e0f3666c4a7674)
Signed-off-by: Shreshtha SAHU <ssahu@nvidia.com>
Reviewed-on: http://git-master/r/1492084
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
drivers/misc/nct1008.c

index 8a77e557a704808317e995786d7b1c410d9526d6..1c002934f3804312e57e743a7a496a4db78dc50e 100644 (file)
@@ -1025,6 +1025,10 @@ static int nct1008_get_trend_as_sensor(int sensor, void *data, int trip,
        int ret, temp, trip_temp, last_temp;
        struct nct1008_data *nct_data = (struct nct1008_data *)data;
        struct thermal_zone_device *thz = nct_data->sensors[sensor].thz;
+       *trend = THERMAL_TREND_STABLE;
+
+       if (!thz)
+               return 0;
 
        ret = thz->ops->get_trip_temp(thz, trip, &trip_temp);
        if (ret)