msm: ipa3: Use vmemdup_user for kernel version 5.10

vmemdup_user has been added to kernel 5.10 symbols
so no need to use memdup_user anymore.

Change-Id: I563da3a1f387ad6a34c28b665686f6e6cd15d6ac
This commit is contained in:
Michael Adisumarta
2021-06-08 19:48:41 -07:00
committed by Gerrit - the friendly Code Review server
parent c25ab41b48
commit ab6b8a4d6c

View File

@@ -11,7 +11,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/rmnet_ipa_fd_ioctl.h> #include <linux/rmnet_ipa_fd_ioctl.h>
#include <linux/version.h>
#include "ipa_qmi_service.h" #include "ipa_qmi_service.h"
#include "ipa_i.h" #include "ipa_i.h"
@@ -97,11 +96,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE :>>>\n", IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct ipa_install_fltr_rule_req_msg_v01); pyld_sz = sizeof(struct ipa_install_fltr_rule_req_msg_v01);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -122,11 +118,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_EX :>>>\n", IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_EX :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01); pyld_sz = sizeof(struct ipa_install_fltr_rule_req_ex_msg_v01);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -147,11 +140,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_ADD_OFFLOAD_CONNECTION :>>>\n", IPAWANDBG("device %s got WAN_IOC_ADD_OFFLOAD_CONNECTION :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct ipa_add_offload_connection_req_msg_v01); pyld_sz = sizeof(struct ipa_add_offload_connection_req_msg_v01);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -173,11 +163,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_RMV_OFFLOAD_CONNECTION :>>>\n", IPAWANDBG("device %s got WAN_IOC_RMV_OFFLOAD_CONNECTION :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = rmv_offload_req__msg_size; pyld_sz = rmv_offload_req__msg_size;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -200,11 +187,8 @@ static long ipa3_wan_ioctl(struct file *filp,
DRIVER_NAME); DRIVER_NAME);
pyld_sz = pyld_sz =
sizeof(struct ipa_configure_ul_firewall_rules_req_msg_v01); sizeof(struct ipa_configure_ul_firewall_rules_req_msg_v01);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -226,11 +210,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_INDEX :>>>\n", IPAWANDBG("device %s got WAN_IOC_ADD_FLT_RULE_INDEX :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct ipa_fltr_installed_notif_req_msg_v01); pyld_sz = sizeof(struct ipa_fltr_installed_notif_req_msg_v01);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -251,11 +232,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG("device %s got WAN_IOC_VOTE_FOR_BW_MBPS :>>>\n", IPAWANDBG("device %s got WAN_IOC_VOTE_FOR_BW_MBPS :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(uint32_t); pyld_sz = sizeof(uint32_t);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -274,11 +252,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_POLL_TETHERING_STATS: case WAN_IOC_POLL_TETHERING_STATS:
IPAWANDBG_LOW("got WAN_IOCTL_POLL_TETHERING_STATS :>>>\n"); IPAWANDBG_LOW("got WAN_IOCTL_POLL_TETHERING_STATS :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_poll_tethering_stats); pyld_sz = sizeof(struct wan_ioctl_poll_tethering_stats);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -299,11 +274,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG_LOW("device %s got WAN_IOCTL_SET_DATA_QUOTA :>>>\n", IPAWANDBG_LOW("device %s got WAN_IOCTL_SET_DATA_QUOTA :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct wan_ioctl_set_data_quota); pyld_sz = sizeof(struct wan_ioctl_set_data_quota);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -359,11 +331,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_SET_TETHER_CLIENT_PIPE: case WAN_IOC_SET_TETHER_CLIENT_PIPE:
IPAWANDBG_LOW("got WAN_IOC_SET_TETHER_CLIENT_PIPE :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_SET_TETHER_CLIENT_PIPE :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_set_tether_client_pipe); pyld_sz = sizeof(struct wan_ioctl_set_tether_client_pipe);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -379,11 +348,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_QUERY_TETHER_STATS: case WAN_IOC_QUERY_TETHER_STATS:
IPAWANDBG_LOW("got WAN_IOC_QUERY_TETHER_STATS :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_QUERY_TETHER_STATS :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_query_tether_stats); pyld_sz = sizeof(struct wan_ioctl_query_tether_stats);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -405,11 +371,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_QUERY_TETHER_STATS_ALL: case WAN_IOC_QUERY_TETHER_STATS_ALL:
IPAWANDBG_LOW("got WAN_IOC_QUERY_TETHER_STATS_ALL :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_QUERY_TETHER_STATS_ALL :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_query_tether_stats_all); pyld_sz = sizeof(struct wan_ioctl_query_tether_stats_all);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -432,11 +395,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG_LOW("device %s got WAN_IOC_RESET_TETHER_STATS :>>>\n", IPAWANDBG_LOW("device %s got WAN_IOC_RESET_TETHER_STATS :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct wan_ioctl_reset_tether_stats); pyld_sz = sizeof(struct wan_ioctl_reset_tether_stats);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -454,11 +414,8 @@ static long ipa3_wan_ioctl(struct file *filp,
IPAWANDBG_LOW("device %s got WAN_IOC_NOTIFY_WAN_STATE :>>>\n", IPAWANDBG_LOW("device %s got WAN_IOC_NOTIFY_WAN_STATE :>>>\n",
DRIVER_NAME); DRIVER_NAME);
pyld_sz = sizeof(struct wan_ioctl_notify_wan_state); pyld_sz = sizeof(struct wan_ioctl_notify_wan_state);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -480,11 +437,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_ENABLE_PER_CLIENT_STATS: case WAN_IOC_ENABLE_PER_CLIENT_STATS:
IPAWANDBG_LOW("got WAN_IOC_ENABLE_PER_CLIENT_STATS :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_ENABLE_PER_CLIENT_STATS :>>>\n");
pyld_sz = sizeof(bool); pyld_sz = sizeof(bool);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -499,11 +453,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_QUERY_PER_CLIENT_STATS: case WAN_IOC_QUERY_PER_CLIENT_STATS:
IPAWANDBG_LOW("got WAN_IOC_QUERY_PER_CLIENT_STATS :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_QUERY_PER_CLIENT_STATS :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_query_per_client_stats); pyld_sz = sizeof(struct wan_ioctl_query_per_client_stats);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -528,11 +479,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_SET_LAN_CLIENT_INFO: case WAN_IOC_SET_LAN_CLIENT_INFO:
IPAWANDBG_LOW("got WAN_IOC_SET_LAN_CLIENT_INFO :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_SET_LAN_CLIENT_INFO :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_lan_client_info); pyld_sz = sizeof(struct wan_ioctl_lan_client_info);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -548,11 +496,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_CLEAR_LAN_CLIENT_INFO: case WAN_IOC_CLEAR_LAN_CLIENT_INFO:
IPAWANDBG_LOW("got WAN_IOC_CLEAR_LAN_CLIENT_INFO :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_CLEAR_LAN_CLIENT_INFO :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_lan_client_info); pyld_sz = sizeof(struct wan_ioctl_lan_client_info);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -569,11 +514,8 @@ static long ipa3_wan_ioctl(struct file *filp,
case WAN_IOC_SEND_LAN_CLIENT_MSG: case WAN_IOC_SEND_LAN_CLIENT_MSG:
IPAWANDBG_LOW("got WAN_IOC_SEND_LAN_CLIENT_MSG :>>>\n"); IPAWANDBG_LOW("got WAN_IOC_SEND_LAN_CLIENT_MSG :>>>\n");
pyld_sz = sizeof(struct wan_ioctl_send_lan_client_msg); pyld_sz = sizeof(struct wan_ioctl_send_lan_client_msg);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
param = memdup_user((const void __user *)arg, pyld_sz);
#else
param = vmemdup_user((const void __user *)arg, pyld_sz); param = vmemdup_user((const void __user *)arg, pyld_sz);
#endif
if (IS_ERR(param)) { if (IS_ERR(param)) {
retval = PTR_ERR(param); retval = PTR_ERR(param);
break; break;
@@ -621,11 +563,7 @@ static long ipa3_wan_ioctl(struct file *filp,
retval = -ENOTTY; retval = -ENOTTY;
} }
if (!IS_ERR(param)) if (!IS_ERR(param))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
kfree(param);
#else
kvfree(param); kvfree(param);
#endif
return retval; return retval;
} }