From patchwork Fri Jun 4 15:39:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 3605 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Fri, 04 Jun 2010 15:39:28 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Fri, 04 Jun 2010 12:41:31 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OKYzX-0006yJ-FW; Fri, 04 Jun 2010 15:39:27 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751825Ab0FDPjZ (ORCPT + 1 other); Fri, 4 Jun 2010 11:39:25 -0400 Received: from mail-ew0-f223.google.com ([209.85.219.223]:37593 "EHLO mail-ew0-f223.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551Ab0FDPjY (ORCPT ); Fri, 4 Jun 2010 11:39:24 -0400 Received: by ewy23 with SMTP id 23so346556ewy.1 for ; Fri, 04 Jun 2010 08:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=YCbwMADm3AYU2S3tHNrMTHa8RGAiF1U5FTRiiimq9+g=; b=r6pMbm8P39ehM1bvrl6EgJ53oeTr24jc46LLGuGapaT64ApT38n+ohtGwO4xWnj5vU J9VBLuwmDprG5autXHIuuJE6Qjxbo1JNFuan372A40fOOchxZlP6SsrAImkK3NcLjBQl WzWKs2ELekvIzVPwRGa/ECRb/d21mHIMXNDL4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=ms6qJnGHYIJHGZe0FMTAYOxfNwDsi/CxvkQKoe+RaTgtcoEa7+YwuFGAyh6Jnkvwql vwKdRAv3rqTOxGu+NxHZZqJ/HgvYdOiGjU9SWqGE8QqXouV0fulXIhHe6laH02Fcd/DQ V9T7+fkzaStfj2V4HdFah+YlUMJN5Oe4gf0Uo= Received: by 10.213.31.143 with SMTP id y15mr3418287ebc.14.1275665960461; Fri, 04 Jun 2010 08:39:20 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id 13sm788388ewy.13.2010.06.04.08.39.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 04 Jun 2010 08:39:19 -0700 (PDT) Date: Fri, 4 Jun 2010 17:39:03 +0200 From: Dan Carpenter To: walter harms Cc: Mauro Carvalho Chehab , Frederic Weisbecker , Arnd Bergmann , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch v2] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user errors Message-ID: <20100604153903.GH5483@bicker> References: <20100604103629.GC5483@bicker> <4C08F0DD.50702@bfs.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4C08F0DD.50702@bfs.de> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org copy_to_user() returns the number of bytes remaining to be copied which isn't the right thing to return here. The comments say that these functions in dvb_ca_en50221.c should return the number of bytes copied or an error return. I've changed it to return -EFAULT. Signed-off-by: Dan Carpenter --- V2: Some style fixes suggested by Walter Harms. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index ef259a0..cb97e6b 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -1318,8 +1318,11 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, fragbuf[0] = connection_id; fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00; - if ((status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen)) != 0) + status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen); + if (status) { + status = -EFAULT; goto exit; + } timeout = jiffies + HZ / 2; written = 0; @@ -1494,8 +1497,11 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf, hdr[0] = slot; hdr[1] = connection_id; - if ((status = copy_to_user(buf, hdr, 2)) != 0) + status = copy_to_user(buf, hdr, 2); + if (status) { + status = -EFAULT; goto exit; + } status = pktlen; exit: