staging: lustre: lov: copy_to_user uses wrong casting
authorJames Simmons <jsimmons@infradead.org>
Mon, 3 Oct 2016 02:28:33 +0000 (22:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Oct 2016 08:24:39 +0000 (10:24 +0200)
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
lustre/lustre/lov/lov_obd.c:1168:
./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 <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6302
Reviewed-on: http://review.whamcloud.com/14613
Reviewed-by: frank zago <fzago@cray.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lov/lov_obd.c

index 473071c..18cb92d 100644 (file)
@@ -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;
                break;
        }