From patchwork Tue Aug 2 05:54:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bernie@plugable.com X-Patchwork-Id: 1028092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p725tA2J005445 for ; Tue, 2 Aug 2011 05:55:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929Ab1HBFzR (ORCPT ); Tue, 2 Aug 2011 01:55:17 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:49365 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866Ab1HBFzQ (ORCPT ); Tue, 2 Aug 2011 01:55:16 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so7707152iyb.19 for ; Mon, 01 Aug 2011 22:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Z+gFeVNgvJT9Sv2jQ+CRF+6gl8StLaxBC7MItQAcffE=; b=g3THKqWAodnvbW2HC50SkuyRl8za71bxdgXb9S41rOS0Cu5FOtowM8/mNMiZDdcS5/ Rxf+xK0CLMhXqQ0bqlQ5SMfOw7BQ8j5JnbSmi4D0Fb3sdTZZBxk+61DUDwYc/ZmOt416 TRkrnyKldGEBFB8JJkwPfRukykA7VGXfsNlAY= Received: by 10.43.134.72 with SMTP id ib8mr3362921icc.94.1312264516178; Mon, 01 Aug 2011 22:55:16 -0700 (PDT) Received: from localhost.localdomain (c-76-22-58-200.hsd1.wa.comcast.net [76.22.58.200]) by mx.google.com with ESMTPS id a10sm3851396iba.58.2011.08.01.22.55.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 01 Aug 2011 22:55:15 -0700 (PDT) From: bernie@plugable.com To: linux-fbdev@vger.kernel.org Cc: lethal@linux-sh.org, "Dr. David Alan Gilbert" , Bernie Thompson Subject: [PATCH 3/5] udlfb: fix issues found with Sparse static analysis Date: Mon, 1 Aug 2011 22:54:30 -0700 Message-Id: <1312264472-2900-3-git-send-email-bernie@plugable.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312264472-2900-1-git-send-email-bernie@plugable.com> References: <1312264472-2900-1-git-send-email-bernie@plugable.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 02 Aug 2011 05:55:17 +0000 (UTC) From: Dr. David Alan Gilbert Add __user casting, a missing copy_from_user, and proper boolean Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Bernie Thompson --- drivers/video/udlfb.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c index bdd21de..f5df3d3 100644 --- a/drivers/video/udlfb.c +++ b/drivers/video/udlfb.c @@ -786,14 +786,13 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd, { struct dlfb_data *dev = info->par; - struct dloarea *area = NULL; if (!atomic_read(&dev->usb_active)) return 0; /* TODO: Update X server to get this from sysfs instead */ if (cmd == DLFB_IOCTL_RETURN_EDID) { - char *edid = (char *)arg; + void __user *edid = (void __user *)arg; if (copy_to_user(edid, dev->edid, dev->edid_size)) return -EFAULT; return 0; @@ -801,6 +800,11 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd, /* TODO: Help propose a standard fb.h ioctl to report mmap damage */ if (cmd == DLFB_IOCTL_REPORT_DAMAGE) { + struct dloarea area; + + if (copy_from_user(&area, (void __user *)arg, + sizeof(struct dloarea))) + return -EFAULT; /* * If we have a damage-aware client, turn fb_defio "off" @@ -812,21 +816,19 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd, if (info->fbdefio) info->fbdefio->delay = DL_DEFIO_WRITE_DISABLE; - area = (struct dloarea *)arg; - - if (area->x < 0) - area->x = 0; + if (area.x < 0) + area.x = 0; - if (area->x > info->var.xres) - area->x = info->var.xres; + if (area.x > info->var.xres) + area.x = info->var.xres; - if (area->y < 0) - area->y = 0; + if (area.y < 0) + area.y = 0; - if (area->y > info->var.yres) - area->y = info->var.yres; + if (area.y > info->var.yres) + area.y = info->var.yres; - dlfb_handle_damage(dev, area->x, area->y, area->w, area->h, + dlfb_handle_damage(dev, area.x, area.y, area.w, area.h, info->screen_base); } @@ -874,7 +876,7 @@ static int dlfb_ops_open(struct fb_info *info, int user) * preventing other clients (X) from working properly. Usually * not what the user wants. Fail by default with option to enable. */ - if ((user == 0) & (!console)) + if ((user == 0) && (!console)) return -EBUSY; /* If the USB device is gone, we don't accept new opens */