From patchwork Sun Aug 21 20:34:15 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: 1083812 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 p7LKYn1k027457 for ; Sun, 21 Aug 2011 20:35:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754354Ab1HUUe7 (ORCPT ); Sun, 21 Aug 2011 16:34:59 -0400 Received: from mail-iy0-f170.google.com ([209.85.210.170]:64871 "EHLO mail-iy0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670Ab1HUUe7 (ORCPT ); Sun, 21 Aug 2011 16:34:59 -0400 Received: by mail-iy0-f170.google.com with SMTP id 16so9119350iye.1 for ; Sun, 21 Aug 2011 13:34:59 -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=dTmrFvwjXYpDKhpGuEk/qdNFUw0YXYt8iis3WCUaIN9HE2j35g0M6ggfVLODN8AUxM uNL4ulNybYm1xdvI2oELlWf2zfJ+LeHKGCNS4ZoxYWjamumep3woOXn7lHh+XR/TZiM1 25aLMa1nI1Z0t49qZZfXw3dVJ1CtLzbGIOOb4= Received: by 10.231.29.22 with SMTP id o22mr1506746ibc.23.1313958898973; Sun, 21 Aug 2011 13:34:58 -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 a9sm2974822ibi.60.2011.08.21.13.34.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Aug 2011 13:34:58 -0700 (PDT) From: bernie@plugable.com To: linux-fbdev@vger.kernel.org Cc: FlorianSchandinat@gmx.de, "Dr. David Alan Gilbert" , Bernie Thompson Subject: [PATCH 3/6] udlfb: fix issues found with Sparse static analysis Date: Sun, 21 Aug 2011 13:34:15 -0700 Message-Id: <1313958862-5640-5-git-send-email-bernie@plugable.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1313958862-5640-1-git-send-email-bernie@plugable.com> References: <1313958862-5640-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]); Sun, 21 Aug 2011 20:35:00 +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 */