thermal: tsens8974: Fix NULL pointer dereference

Dereference the thermal device pointer only after checking
that it is valid.

Change-Id: I5619b14f2d37969e59a16a64b6011c1dba9b2e15
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
This commit is contained in:
Stepan Moskovchenko 2012-08-06 14:35:09 -07:00 committed by Stephen Boyd
parent 8f5cb3f56b
commit 4a26cc02e3

View file

@ -771,7 +771,7 @@ fail:
static int __devinit _tsens_register_thermal(void)
{
struct platform_device *pdev = tmdev->pdev;
struct platform_device *pdev;
int rc, i;
if (!tmdev) {
@ -779,6 +779,8 @@ static int __devinit _tsens_register_thermal(void)
return -ENODEV;
}
pdev = tmdev->pdev;
for (i = 0; i < tmdev->tsens_num_sensor; i++) {
char name[18];
snprintf(name, sizeof(name), "tsens_tz_sensor%d", i);