thermal/int340x_thermal: handle data_vault when the value is ZERO_SIZE_PTR
authorLee, Chun-Yi <joeyli.kernel@gmail.com>
Mon, 8 Aug 2022 13:21:58 +0000 (21:21 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 23 Aug 2022 17:50:43 +0000 (19:50 +0200)
commit7931e28098a4c1a2a6802510b0cbe57546d2049d
treea1ae24264c8b266db0f0af7c2fb33b2b1825243d
parent1c23f9e627a7b412978b4e852793c5e3c3efc555
thermal/int340x_thermal: handle data_vault when the value is ZERO_SIZE_PTR

In some case, the GDDV returns a package with a buffer which has
zero length. It causes that kmemdup() returns ZERO_SIZE_PTR (0x10).

Then the data_vault_read() got NULL point dereference problem when
accessing the 0x10 value in data_vault.

[   71.024560] BUG: kernel NULL pointer dereference, address:
0000000000000010

This patch uses ZERO_OR_NULL_PTR() for checking ZERO_SIZE_PTR or
NULL value in data_vault.

Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/intel/int340x_thermal/int3400_thermal.c