Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933664AbbFWNvl (ORCPT ); Tue, 23 Jun 2015 09:51:41 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:22059 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932788AbbFWNvd (ORCPT ); Tue, 23 Jun 2015 09:51:33 -0400 Date: Tue, 23 Jun 2015 16:51:24 +0300 From: Dan Carpenter To: Dmitry Kalinkin Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Martyn Welch , Greg Kroah-Hartman , Manohar Vanga Subject: Re: [PATCH 6/9] staging: vme_user: return -EFAULT on __copy_*_user errors Message-ID: <20150623135124.GP28762@mwanda> References: <1435063353-25914-1-git-send-email-dmitry.kalinkin@gmail.com> <1435063353-25914-7-git-send-email-dmitry.kalinkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435063353-25914-7-git-send-email-dmitry.kalinkin@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1586 Lines: 59 On Tue, Jun 23, 2015 at 03:42:30PM +0300, Dmitry Kalinkin wrote: > @@ -178,38 +167,24 @@ static ssize_t buffer_to_user(unsigned int minor, char __user *buf, > size_t count, loff_t *ppos) > { > void *image_ptr; > - ssize_t retval; > > image_ptr = image[minor].kern_buf + *ppos; > + if (__copy_to_user(buf, image_ptr, (unsigned long)count)) > + return -EINVAL; s/EINVAL/EFAULT/ > > - retval = __copy_to_user(buf, image_ptr, (unsigned long)count); > - if (retval != 0) { > - retval = (count - retval); > - pr_warn("Partial copy to userspace\n"); > - } else > - retval = count; > - > - /* Return number of bytes successfully read */ > - return retval; > + return count; > } > > static ssize_t buffer_from_user(unsigned int minor, const char __user *buf, > size_t count, loff_t *ppos) > { > void *image_ptr; > - size_t retval; > > image_ptr = image[minor].kern_buf + *ppos; > + if (__copy_from_user(image_ptr, buf, (unsigned long)count)) > + return -EINVAL; s/EINVAL/EFAULT/ > > - retval = __copy_from_user(image_ptr, buf, (unsigned long)count); > - if (retval != 0) { > - retval = (count - retval); > - pr_warn("Partial copy to userspace\n"); > - } else > - retval = count; > - > - /* Return number of bytes successfully read */ > - return retval; > + return count; > } regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/