diff --git a/net/core/pktgen.c b/net/core/pktgen.c index fdac61cac1bd11b15a69f78584029731e9310e4e..cc07c434948a3c6a99ccce0c42d14162a333433f 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -485,6 +485,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, goto out; } + if (count == 0) + return -EINVAL; + if (count > sizeof(data)) count = sizeof(data); @@ -492,7 +495,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, err = -EFAULT; goto out; } - data[count - 1] = 0; /* Make string */ + data[count - 1] = 0; /* Strip trailing '\n' and terminate string */ if (!strcmp(data, "stop")) pktgen_stop_all_threads_ifs(pn);