diff --git a/drivers/nfc/st21nfc/st21nfc.c b/drivers/nfc/st21nfc/st21nfc.c index 5682b0b45ac3..090a755a208b 100644 --- a/drivers/nfc/st21nfc/st21nfc.c +++ b/drivers/nfc/st21nfc/st21nfc.c @@ -384,11 +384,19 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd, * from the kernel perspective; so they look reversed. */ if (_IOC_DIR(cmd) & _IOC_READ) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) + ret = !access_ok((void __user *)arg, _IOC_SIZE(cmd)); +#else ret = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); +#endif if (ret == 0 && _IOC_DIR(cmd) & _IOC_WRITE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) + ret = !access_ok((void __user *)arg, _IOC_SIZE(cmd)); +#else ret = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); +#endif if (ret) return -EFAULT;