Skip to content

Commit 13b86f5

Browse files
jwrdegoedezhang-rui
authored andcommitted
thermal: int3403_thermal: Fix NULL pointer deref on module load / probe
Starting with kernel 4.17 thermal_cooling_device_register() will call the get_max_state() op during register. Since we deref priv->priv in int3403_get_max_state() this means we must set priv->priv before calling thermal_cooling_device_register(). Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Zhang Rui <[email protected]>
1 parent 6d08b06 commit 13b86f5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/thermal/int340x_thermal/int3403_thermal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,14 @@ static int int3403_cdev_add(struct int3403_priv *priv)
194194
return -EFAULT;
195195
}
196196

197+
priv->priv = obj;
197198
obj->max_state = p->package.count - 1;
198199
obj->cdev =
199200
thermal_cooling_device_register(acpi_device_bid(priv->adev),
200201
priv, &int3403_cooling_ops);
201202
if (IS_ERR(obj->cdev))
202203
result = PTR_ERR(obj->cdev);
203204

204-
priv->priv = obj;
205-
206205
kfree(buf.pointer);
207206
/* TODO: add ACPI notification support */
208207

0 commit comments

Comments
 (0)