kernel: ltq-vdsl-vr9-mei: Fix compilation with Linux 5.15

The result of copy_to_user() now has to be checked explicitly. Also
MODULE_SUPPORTED_DEVICE is gone after Linux 5.10.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
This commit is contained in:
Martin Blumenstingl 2022-03-21 20:21:04 +01:00 committed by Hauke Mehrtens
parent 22fbc2d896
commit f4ce7df4fc
2 changed files with 71 additions and 10 deletions

View File

@ -43,7 +43,18 @@
#ifdef MODULE
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
MODULE_PARM(major_number, "b");
@@ -1479,7 +1483,11 @@ struct proc_entry {
@@ -1256,7 +1260,9 @@ static long MEI_Ioctl( struct file *filp
MEI_IOCTL_RETURN:
local_args.drv_ioctl.retCode = ret;
- copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize);
+ if ( ret == IFX_SUCCESS &&
+ copy_to_user( ((IOCTL_MEI_arg_t *)nArgument), &local_args, retSize) )
+ ret = -e_MEI_ERR_RETURN_ARG;
return (ret < 0) ? -1 : 0;
}
@@ -1479,7 +1485,11 @@ struct proc_entry {
char name[32];
proc_rd_callback_t rd;
proc_wr_callback_t wr;
@ -55,7 +66,7 @@
int entity;
};
@@ -1869,6 +1877,7 @@ static int mei_proc_single_open(struct i
@@ -1869,6 +1879,7 @@ static int mei_proc_single_open(struct i
static void mei_proc_entry_create(struct proc_dir_entry *parent_node,
struct proc_entry *proc_entry)
{
@ -63,7 +74,7 @@
memset(&proc_entry->ops, 0, sizeof(struct file_operations));
proc_entry->ops.owner = THIS_MODULE;
@@ -1879,6 +1888,17 @@ static void mei_proc_entry_create(struct
@@ -1879,6 +1890,17 @@ static void mei_proc_entry_create(struct
proc_entry->ops.llseek = seq_lseek;
if (proc_entry->wr)
proc_entry->ops.write = proc_entry->wr;
@ -81,7 +92,7 @@
proc_create_data(proc_entry->name,
(S_IFREG | S_IRUGO),
@@ -2174,9 +2194,11 @@ static int MEI_module_init (void)
@@ -2174,9 +2196,11 @@ static int MEI_module_init (void)
return (result);
}
@ -93,7 +104,7 @@
return 0;
}
@@ -2304,6 +2326,10 @@ static void MEI_module_exit (void)
@@ -2304,6 +2328,10 @@ static void MEI_module_exit (void)
#else
unregister_chrdev ( major_number , DRV_MEI_NAME );
@ -104,7 +115,7 @@
#endif
#if CONFIG_PROC_FS
@@ -2388,9 +2414,11 @@ static void MEI_module_exit (void)
@@ -2388,9 +2416,11 @@ static void MEI_module_exit (void)
("MEI_DRV: Chipset Basic Exit failed" MEI_DRV_CRLF));
}
@ -116,7 +127,7 @@
#if (MEI_SUPPORT_DEBUG_LOGGER == 1)
if (nl_debug_sock)
@@ -2514,6 +2542,10 @@ static int MEI_InitModuleRegCharDev(cons
@@ -2514,6 +2544,10 @@ static int MEI_InitModuleRegCharDev(cons
("Using major number %d" MEI_DRV_CRLF, major_number));
}
@ -127,7 +138,7 @@
return 0;
#endif /* CONFIG_DEVFS_FS */
}
@@ -2563,21 +2595,32 @@ static int MEI_InitModuleBasics(void)
@@ -2563,21 +2597,32 @@ static int MEI_InitModuleBasics(void)
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
@ -160,7 +171,7 @@
return 0;
}
@@ -2905,11 +2948,15 @@ IFX_int32_t MEI_IoctlInitDevice(
@@ -2905,11 +2950,15 @@ IFX_int32_t MEI_IoctlInitDevice(
pMeiDev->eModePoll = e_MEI_DEV_ACCESS_MODE_IRQ;
pMeiDev->intMask = ME_ARC2ME_INTERRUPT_UNMASK_ALL;
@ -176,6 +187,46 @@
pTmpXCntrl = MEI_VrxXDevToIrqListAdd(
MEI_DRV_LINENUM_GET(pMeiDev),
@@ -3249,9 +3298,11 @@ static int MEI_IoctlMeiDbgAccessWr_Wrap(
ret = MEI_IoctlMeiDbgAccessWr( pMeiDynCntrl, pLocalArgument);
/* return arguments - count */
- copy_to_user( (void *)&pUserArgument->count,
- (void *)&pLocalArgument->count,
- sizeof(pUserArgument->count) ) ;
+ if ( ret == IFX_SUCCESS &&
+ copy_to_user( (void *)&pUserArgument->count,
+ (void *)&pLocalArgument->count,
+ sizeof(pUserArgument->count) ) )
+ ret = -e_MEI_ERR_RETURN_ARG;
return ret;
}
@@ -3278,16 +3329,18 @@ static int MEI_IoctlMeiDbgAccessRd_Wrap(
if ( pLocalArgument->count )
{
/* return the buffer */
- copy_to_user( pUserBuf,
- pLocalArgument->pData_32,
- pLocalArgument->count * sizeof(IFX_uint32_t) ) ;
+ if ( copy_to_user( pUserBuf,
+ pLocalArgument->pData_32,
+ pLocalArgument->count * sizeof(IFX_uint32_t) ) )
+ ret = -e_MEI_ERR_RETURN_ARG;
}
/* return count argument */
- copy_to_user( (void *)&pUserArgument->count,
- (void *)&pLocalArgument->count,
- sizeof(pUserArgument->count) ) ;
+ if ( copy_to_user( (void *)&pUserArgument->count,
+ (void *)&pLocalArgument->count,
+ sizeof(pUserArgument->count) ) )
+ ret = -e_MEI_ERR_RETURN_ARG;
return ret;
}
--- a/src/drv_mei_cpe_api_atm_ptm_intern.c
+++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
@@ -147,6 +147,7 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit

View File

@ -1,6 +1,6 @@
--- a/src/drv_mei_cpe_linux.c
+++ b/src/drv_mei_cpe_linux.c
@@ -1503,8 +1503,8 @@ struct proc_entry {
@@ -1505,8 +1505,8 @@ struct proc_entry {
static void MEI_GetVersionProc(struct seq_file *s)
{
seq_printf(s, "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]);
@ -11,3 +11,13 @@
}
/**
@@ -4233,7 +4233,9 @@ module_exit (MEI_module_exit);
#ifdef MODULE
MODULE_AUTHOR("www.lantiq.com");
MODULE_DESCRIPTION("MEI CPE Driver - www.lantiq.com");
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0))
MODULE_SUPPORTED_DEVICE("MEI CPE Interface");
+#endif
MODULE_LICENSE ("GPL");
#endif /* #ifdef MODULE*/