Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp245554pxf; Wed, 10 Mar 2021 05:33:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1F8GeOuyKbTq8H6TGJKFOMtxLqyl22zuNwerIsZZicjzXvqztDiVDzZ0hUS+1KMQHLogL X-Received: by 2002:a17:906:f896:: with SMTP id lg22mr3599279ejb.124.1615383236833; Wed, 10 Mar 2021 05:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383236; cv=none; d=google.com; s=arc-20160816; b=eJ4IgFeAjUXap8F75Z68DLQg1our3/sUqZ9nzSzgQHBDP5bjBFuxJ5dSfF8+yLfomU P1G+4kMGj42Pm/AcDdlXdczq5WWQ8Q0YQw6YV8ES4UTx/qL6DonrD5x1OeiRRj5tw77j 7+hZL4s1LPJafj+eoZXB9beUBQkAoPMmUaDDLxNaTGQ482kHBvk9IYF69ZbbTQwq4t1p SnOPQgjkVJTh+TJs3HsfV+0HI1ZyKyq7TaZ2RQvhveE71v8QDfagdDLy6sc9MOdZOaBz yexCRQhbCO8dVOlolf7xI8nYsT4UiaUsHIjyABOvTngdR7XvYx+bbCYiQkCmyZoom8NA wPfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1yGiNc8iWBFz1ySnpxJzMuqx1ukNfLhLHgxpr4wL5VQ=; b=HlTacfxOHwRW/dPQi9+5UKWOdEMgtn5EC+cmjgQuSrqO6fYwYDLCAKgE7IfY1FCr6y 8nj8Z6MQ/TwcXd3yjdsfjX1eZvs3FvQ0UVGnSYd/4c1nI7TsIVN7daAkxr5C8kj1jwya XrlJ9cC5HqoQeVACO43cYsNvcBCfUZ/59ya2c4+QBlqe1m1j/mer41O1Z+c7w68LNJoD /lpf5cmpqm0dZIxoKQeNZ9PqI1GO8DH5Z+HzuIy/nhkgu3qk7KLeqemxk79p6U9qyAYp 0NoX46tafrPiDFrXK767o9BCMBQNNmHV9fLlRUl5QWsmg/OvM+affwupU8ib4ulnrkDm P7bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DoFjufAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si3868397ejm.461.2021.03.10.05.33.33; Wed, 10 Mar 2021 05:33:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DoFjufAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234401AbhCJNaU (ORCPT + 99 others); Wed, 10 Mar 2021 08:30:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:48260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233410AbhCJNZf (ORCPT ); Wed, 10 Mar 2021 08:25:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBA3B6505D; Wed, 10 Mar 2021 13:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382732; bh=qmeS8Y8iMDaHYqIdr1U2Je+1CREBFhlFNSF9Z648Xoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoFjufAzl+i4ZvWRRAfQtMnqETz46VzAyLRvfWOw6ybEhlivecPbQp3WSOjg3Dok+ bQr7x6AqvQfCp0kFBDdG9jXUk+rDmame2Py7Qtp/SCqmMZHwn3L5oZ6n7hbAkwis/Y d9vh2dyiN8p7aHZ8I+mGVyI16hecBrlBUMy9wDtU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jens Axboe , Sasha Levin Subject: [PATCH 4.4 4/7] rsxx: Return -EFAULT if copy_to_user() fails Date: Wed, 10 Mar 2021 14:25:17 +0100 Message-Id: <20210310132319.318920870@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.155338551@linuxfoundation.org> References: <20210310132319.155338551@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Dan Carpenter [ Upstream commit 77516d25f54912a7baedeeac1b1b828b6f285152 ] The copy_to_user() function returns the number of bytes remaining but we want to return -EFAULT to the user if it can't complete the copy. The "st" variable only holds zero on success or negative error codes on failure so the type should be int. Fixes: 36f988e978f8 ("rsxx: Adding in debugfs entries.") Signed-off-by: Dan Carpenter Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/rsxx/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index 620a3a67cdd5..0d9137408e3c 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c @@ -180,15 +180,17 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf, { struct rsxx_cardinfo *card = file_inode(fp)->i_private; char *buf; - ssize_t st; + int st; buf = kzalloc(cnt, GFP_KERNEL); if (!buf) return -ENOMEM; st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1); - if (!st) - st = copy_to_user(ubuf, buf, cnt); + if (!st) { + if (copy_to_user(ubuf, buf, cnt)) + st = -EFAULT; + } kfree(buf); if (st) return st; -- 2.30.1