Skip to content

Commit

Permalink
hwmon: (s3c-hwmon) Ignore invalid divider settings
Browse files Browse the repository at this point in the history
Avoid registering channels that have zero divider settings in them, as this
will only lead to kernel OOPS from divide-by-zero when the sysfs entry is
read.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Ben Dooks authored and Jean Delvare committed Nov 16, 2009
1 parent a9366e6 commit be4c23c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/hwmon/s3c-hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,21 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev)
}

for (i = 0; i < ARRAY_SIZE(pdata->in); i++) {
if (!pdata->in[i])
struct s3c24xx_adc_hwmon_incfg *cfg = pdata->in[i];

if (!cfg)
continue;

if (pdata->in[i]->mult >= 0x10000)
if (cfg->mult >= 0x10000)
dev_warn(&dev->dev,
"channel %d multiplier too large\n",
i);

if (cfg->divider == 0) {
dev_err(&dev->dev, "channel %d divider zero\n", i);
continue;
}

ret = s3c_hwmon_create_attr(&dev->dev, pdata->in[i],
&hwmon->attrs[i], i);
if (ret) {
Expand Down

0 comments on commit be4c23c

Please sign in to comment.