diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h index 0021f4773f7e679077233ca0163658b578c3354d..e58b5959e17c76e67767d29eb68c842ef808496c 100644 --- a/drivers/ptp/ptp_private.h +++ b/drivers/ptp/ptp_private.h @@ -20,6 +20,7 @@ #define PTP_MAX_TIMESTAMPS 128 #define PTP_BUF_TIMESTAMPS 30 #define PTP_DEFAULT_MAX_VCLOCKS 20 +#define PTP_MAX_VCLOCKS_LIMIT (KMALLOC_MAX_SIZE/(sizeof(int))) struct timestamp_event_queue { struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS]; diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index aefc06ae5d099514959b056b89c2f0bbe455ad7f..02111e6d87a10fdb5989b5a43ef00b08aeb131a5 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -282,7 +282,7 @@ static ssize_t max_vclocks_store(struct device *dev, size_t size; u32 max; - if (kstrtou32(buf, 0, &max) || max == 0) + if (kstrtou32(buf, 0, &max) || max == 0 || max > PTP_MAX_VCLOCKS_LIMIT) return -EINVAL; if (max == ptp->max_vclocks)