aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/udlfb.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <linux@treblig.org>2011-08-21 16:34:15 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-08-24 06:09:57 -0400
commitdef76608681983c1fe70c0fa780d8fe777442ef5 (patch)
treeddd23a12801ea46db016d30ebe7f2f6b7a913c20 /drivers/video/udlfb.c
parentf2e1fc9d5d12fbc06590ac4987dce6f79d86f1c7 (diff)
udlfb: fix issues found with Sparse static analysis
Add __user casting, a missing copy_from_user, and proper boolean Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org> Signed-off-by: Bernie Thompson <bernie@plugable.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/udlfb.c')
-rw-r--r--drivers/video/udlfb.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
index 0b77af7bdf1b..37498abcd917 100644
--- a/drivers/video/udlfb.c
+++ b/drivers/video/udlfb.c
@@ -776,14 +776,13 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd,
776{ 776{
777 777
778 struct dlfb_data *dev = info->par; 778 struct dlfb_data *dev = info->par;
779 struct dloarea *area = NULL;
780 779
781 if (!atomic_read(&dev->usb_active)) 780 if (!atomic_read(&dev->usb_active))
782 return 0; 781 return 0;
783 782
784 /* TODO: Update X server to get this from sysfs instead */ 783 /* TODO: Update X server to get this from sysfs instead */
785 if (cmd == DLFB_IOCTL_RETURN_EDID) { 784 if (cmd == DLFB_IOCTL_RETURN_EDID) {
786 char *edid = (char *)arg; 785 void __user *edid = (void __user *)arg;
787 if (copy_to_user(edid, dev->edid, dev->edid_size)) 786 if (copy_to_user(edid, dev->edid, dev->edid_size))
788 return -EFAULT; 787 return -EFAULT;
789 return 0; 788 return 0;
@@ -791,6 +790,11 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd,
791 790
792 /* TODO: Help propose a standard fb.h ioctl to report mmap damage */ 791 /* TODO: Help propose a standard fb.h ioctl to report mmap damage */
793 if (cmd == DLFB_IOCTL_REPORT_DAMAGE) { 792 if (cmd == DLFB_IOCTL_REPORT_DAMAGE) {
793 struct dloarea area;
794
795 if (copy_from_user(&area, (void __user *)arg,
796 sizeof(struct dloarea)))
797 return -EFAULT;
794 798
795 /* 799 /*
796 * If we have a damage-aware client, turn fb_defio "off" 800 * If we have a damage-aware client, turn fb_defio "off"
@@ -802,21 +806,19 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd,
802 if (info->fbdefio) 806 if (info->fbdefio)
803 info->fbdefio->delay = DL_DEFIO_WRITE_DISABLE; 807 info->fbdefio->delay = DL_DEFIO_WRITE_DISABLE;
804 808
805 area = (struct dloarea *)arg; 809 if (area.x < 0)
806 810 area.x = 0;
807 if (area->x < 0)
808 area->x = 0;
809 811
810 if (area->x > info->var.xres) 812 if (area.x > info->var.xres)
811 area->x = info->var.xres; 813 area.x = info->var.xres;
812 814
813 if (area->y < 0) 815 if (area.y < 0)
814 area->y = 0; 816 area.y = 0;
815 817
816 if (area->y > info->var.yres) 818 if (area.y > info->var.yres)
817 area->y = info->var.yres; 819 area.y = info->var.yres;
818 820
819 dlfb_handle_damage(dev, area->x, area->y, area->w, area->h, 821 dlfb_handle_damage(dev, area.x, area.y, area.w, area.h,
820 info->screen_base); 822 info->screen_base);
821 } 823 }
822 824
@@ -864,7 +866,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)
864 * preventing other clients (X) from working properly. Usually 866 * preventing other clients (X) from working properly. Usually
865 * not what the user wants. Fail by default with option to enable. 867 * not what the user wants. Fail by default with option to enable.
866 */ 868 */
867 if ((user == 0) & (!console)) 869 if ((user == 0) && (!console))
868 return -EBUSY; 870 return -EBUSY;
869 871
870 /* If the USB device is gone, we don't accept new opens */ 872 /* If the USB device is gone, we don't accept new opens */