]> git.sur5r.net Git - groeck-nct6775/blobdiff - nct6775.c
Check for invalid temperature source
[groeck-nct6775] / nct6775.c
index 94b304620c2475856bca1e8de2c79a904ffc8ec0..6e21ffbd34d5372538d07acbde5971b84fa572cd 100644 (file)
--- a/nct6775.c
+++ b/nct6775.c
@@ -399,7 +399,7 @@ static const char *const nct6779_temp_label[] = {
        "BYTE_TEMP"
 };
 
-static const u16 NCT6775_REG_TEMP_ALTERNATE[ARRAY_SIZE(nct6779_temp_label)]
+static const u16 NCT6775_REG_TEMP_ALTERNATE[ARRAY_SIZE(nct6775_temp_label)]
        = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x661, 0x662, 0x664 };
 
 static const u16 NCT6776_REG_TEMP_ALTERNATE[ARRAY_SIZE(nct6776_temp_label)]
@@ -3090,7 +3090,6 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
        switch (data->kind) {
        case nct6775:
                data->in_num = 9;
-               data->have_in = 0x1ff;
                data->pwm_num = 3;
                data->auto_pwm_num = 6;
                data->has_fan_div = true;
@@ -3150,7 +3149,6 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                break;
        case nct6776:
                data->in_num = 9;
-               data->have_in = 0x1ff;
                data->pwm_num = 3;
                data->auto_pwm_num = 4;
                data->has_fan_div = false;
@@ -3209,7 +3207,6 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                break;
        case nct6779:
                data->in_num = 15;
-               data->have_in = 0x7fff;
                data->pwm_num = 5;
                data->auto_pwm_num = 4;
                data->has_fan_div = false;
@@ -3270,7 +3267,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                err = -ENODEV;
                goto exit_release;
        }
-
+       data->have_in = (1 << data->in_num) - 1;
        data->have_temp = 0;
 
        /*
@@ -3333,6 +3330,12 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                if (!src || (mask & (1 << src)))
                        continue;
 
+               if (src >= data->temp_label_num ||
+                   !strlen(data->temp_label[src])) {
+                       dev_info(dev, "Invalid temperature source %d\n", src);
+                       continue;
+               }
+
                mask |= 1 << src;
 
                /* Use fixed index for SYSTIN(1), CPUTIN(2), AUXTIN(3) */
@@ -3474,7 +3477,8 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                }
                superio_outb(sio_data->sioreg, NCT6775_REG_CR_FAN_DEBOUNCE,
                             tmp);
-               pr_info("Enabled fan debounce for chip %s\n", data->name);
+               dev_info(&pdev->dev, "Enabled fan debounce for chip %s\n",
+                        data->name);
        }
 
        superio_exit(sio_data->sioreg);
@@ -3588,8 +3592,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
                err = device_create_file(dev, &sda_temp_type[i].dev_attr);
                if (err)
                        goto exit_remove;
-               err = device_create_file(dev,
-                                        &sda_temp_offset[i].dev_attr);
+               err = device_create_file(dev, &sda_temp_offset[i].dev_attr);
                if (err)
                        goto exit_remove;
                if (i >= NUM_TEMP_ALARM ||