--- linux-4.9.37/drivers/i2c/i2c-dev.c 2017-07-12 16:42:41.000000000 +0300 +++ linux-4.9.y/drivers/i2c/i2c-dev.c 2021-06-07 13:01:33.000000000 +0300 @@ -170,6 +170,9 @@ if (count > 8192) count = 8192; + if (count == 0) + return -EINVAL; + tmp = memdup_user(buf, count); if (IS_ERR(tmp)) return PTR_ERR(tmp); @@ -273,6 +276,11 @@ res = -EINVAL; break; } + + if (rdwr_pa[i].len == 0) { + res = -EINVAL; + break; + } data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf; rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);