Skip to content

Commit 9da21b1

Browse files
committed
EDAC: Poll timeout cannot be zero, p2
Sanitize code even more to accept unsigned longs only and to not allow polling intervals below 1 second as this is unnecessary and doesn't make much sense anyway for polling errors. Signed-off-by: Borislav Petkov <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Cc: Doug Thompson <[email protected]> Cc: <[email protected]>
1 parent 4675348 commit 9da21b1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

drivers/edac/edac_mc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static void edac_mc_workq_teardown(struct mem_ctl_info *mci)
601601
* user space has updated our poll period value, need to
602602
* reset our workq delays
603603
*/
604-
void edac_mc_reset_delay_period(int value)
604+
void edac_mc_reset_delay_period(unsigned long value)
605605
{
606606
struct mem_ctl_info *mci;
607607
struct list_head *item;
@@ -611,7 +611,7 @@ void edac_mc_reset_delay_period(int value)
611611
list_for_each(item, &mc_devices) {
612612
mci = list_entry(item, struct mem_ctl_info, link);
613613

614-
edac_mc_workq_setup(mci, (unsigned long) value);
614+
edac_mc_workq_setup(mci, value);
615615
}
616616

617617
mutex_unlock(&mem_ctls_mutex);

drivers/edac/edac_mc_sysfs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,20 @@ int edac_mc_get_poll_msec(void)
5252

5353
static int edac_set_poll_msec(const char *val, struct kernel_param *kp)
5454
{
55-
long l;
55+
unsigned long l;
5656
int ret;
5757

5858
if (!val)
5959
return -EINVAL;
6060

61-
ret = kstrtol(val, 0, &l);
61+
ret = kstrtoul(val, 0, &l);
6262
if (ret)
6363
return ret;
64-
if (!l || ((int)l != l))
64+
65+
if (l < 1000)
6566
return -EINVAL;
66-
*((int *)kp->arg) = l;
67+
68+
*((unsigned long *)kp->arg) = l;
6769

6870
/* notify edac_mc engine to reset the poll period */
6971
edac_mc_reset_delay_period(l);

drivers/edac/edac_module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
5252
extern void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev);
5353
extern void edac_device_reset_delay_period(struct edac_device_ctl_info
5454
*edac_dev, unsigned long value);
55-
extern void edac_mc_reset_delay_period(int value);
55+
extern void edac_mc_reset_delay_period(unsigned long value);
5656

5757
extern void *edac_align_ptr(void **p, unsigned size, int n_elems);
5858

0 commit comments

Comments
 (0)