[lkml]   [2016]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 37/41] staging: lustre: lov: copy_to_user uses wrong casting
With certain version of gcc lov_obd.c failes to compile
with the following warning.

In function copy_to_user,
inlined from lov_iocontrol at
./arch/x86/include/asm/uaccess.h:735: error: call to
__copy_to_user_overflow declared with attribute warning:
copy_to_user() buffer size is not probably correct

In lov_iocontrol the data was being casted to int instead
of the required unsigned long. This patch changes the cast
to what is needed for copy_to_user.

Signed-off-by: James Simmons <>
Reviewed-by: frank zago <>
Reviewed-by: Dmitry Eremin <>
Reviewed-by: John L. Hammond <>
Reviewed-by: Oleg Drokin <>
Signed-off-by: James Simmons <>
drivers/staging/lustre/lustre/lov/lov_obd.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 473071c..18cb92d 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1085,8 +1085,8 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,

/* copy UUID */
if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd),
- min((int)data->ioc_plen2,
- (int)sizeof(struct obd_uuid))))
+ min_t(unsigned long, data->ioc_plen2,
+ sizeof(struct obd_uuid))))
return -EFAULT;

memcpy(&flags, data->ioc_inlbuf1, sizeof(__u32));
@@ -1099,8 +1099,8 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
if (rc)
return rc;
if (copy_to_user(data->ioc_pbuf1, &stat_buf,
- min((int)data->ioc_plen1,
- (int)sizeof(stat_buf))))
+ min_t(unsigned long, data->ioc_plen1,
+ sizeof(stat_buf))))
return -EFAULT;
 \ /
  Last update: 2016-10-03 04:32    [W:0.173 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site