linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Dan Carpenter <dan.carpenter@oracle.com>,
	Jens Axboe <axboe@kernel.dk>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 37/42] rsxx: Return -EFAULT if copy_to_user() fails
Date: Mon,  8 Mar 2021 13:31:03 +0100	[thread overview]
Message-ID: <20210308122719.928917471@linuxfoundation.org> (raw)
In-Reply-To: <20210308122718.120213856@linuxfoundation.org>

From: Dan Carpenter <dan.carpenter@oracle.com>

[ 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 <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 63f549889f87..5ac1881396af 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -165,15 +165,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




  parent reply	other threads:[~2021-03-08 12:35 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 12:30 [PATCH 5.10 00/42] 5.10.22-rc1 review Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 01/42] ALSA: hda/realtek: Enable headset mic of Acer SWIFT with ALC256 Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 02/42] ALSA: usb-audio: use Corsair Virtuoso mapping for Corsair Virtuoso SE Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 03/42] ALSA: usb-audio: Drop bogus dB range in too low level Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 04/42] tpm, tpm_tis: Decorate tpm_tis_gen_interrupt() with request_locality() Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 05/42] tpm, tpm_tis: Decorate tpm_get_timeouts() " Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 06/42] btrfs: avoid double put of block group when emptying cluster Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 07/42] btrfs: fix raid6 qstripe kmap Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 08/42] btrfs: fix race between writes to swap files and scrub Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 09/42] btrfs: fix race between swap file activation and snapshot creation Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 10/42] btrfs: fix stale data exposure after cloning a hole with NO_HOLES enabled Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 11/42] btrfs: fix race between extent freeing/allocation when using bitmaps Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 12/42] btrfs: validate qgroup inherit for SNAP_CREATE_V2 ioctl Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 13/42] btrfs: free correct amount of space in btrfs_delayed_inode_reserve_metadata Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 14/42] btrfs: unlock extents in btrfs_zero_range in case of quota reservation errors Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 15/42] btrfs: fix warning when creating a directory with smack enabled Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 16/42] PM: runtime: Update device status before letting suppliers suspend Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 17/42] ring-buffer: Force before_stamp and write_stamp to be different on discard Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 18/42] io_uring: ignore double poll add on the same waitqueue head Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 19/42] dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 20/42] dm verity: fix FEC for RS roots unaligned to block size Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 21/42] drm/amdgpu:disable VCN for Navi12 SKU Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 22/42] drm/amdgpu: fix parameter error of RREG32_PCIE() in amdgpu_regs_pcie Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 23/42] crypto - shash: reduce minimum alignment of shash_desc structure Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 24/42] arm64: mm: Move reserve_crashkernel() into mem_init() Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 25/42] arm64: mm: Move zone_dma_bits initialization into zone_sizes_init() Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 26/42] of/address: Introduce of_dma_get_max_cpu_address() Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 27/42] of: unittest: Add test for of_dma_get_max_cpu_address() Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 28/42] arm64: mm: Set ZONE_DMA size based on devicetrees dma-ranges Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 29/42] arm64: mm: Set ZONE_DMA size based on early IORT scan Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 30/42] mm: Remove examples from enum zone_type comment Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 31/42] ALSA: ctxfi: cthw20k2: fix mask on conf to allow 4 bits Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 32/42] RDMA/cm: Fix IRQ restore in ib_send_cm_sidr_rep Greg Kroah-Hartman
2021-03-08 12:30 ` [PATCH 5.10 33/42] RDMA/rxe: Fix missing kconfig dependency on CRYPTO Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 34/42] IB/mlx5: Add missing error code Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 35/42] ALSA: hda: intel-nhlt: verify config type Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 36/42] ftrace: Have recordmcount use w8 to read relp->r_info in arm64_is_fake_mcount Greg Kroah-Hartman
2021-03-08 12:31 ` Greg Kroah-Hartman [this message]
2021-03-08 12:31 ` [PATCH 5.10 38/42] iommu/vt-d: Fix status code for Allocate/Free PASID command Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 39/42] Revert "arm64: dts: amlogic: add missing ethernet reset ID" Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 40/42] of: unittest: Fix build on architectures without CONFIG_OF_ADDRESS Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 41/42] tomoyo: recognize kernel threads correctly Greg Kroah-Hartman
2021-03-08 12:31 ` [PATCH 5.10 42/42] r8169: fix resuming from suspend on RTL8105e if machine runs on battery Greg Kroah-Hartman
2021-03-08 17:50 ` [PATCH 5.10 00/42] 5.10.22-rc1 review Florian Fainelli
2021-03-08 20:35 ` Pavel Machek
2021-03-08 22:29 ` Guenter Roeck
2021-03-09  1:08 ` Samuel Zou
2021-03-09 10:27   ` Greg Kroah-Hartman
2021-03-09 10:27   ` Greg Kroah-Hartman
2021-03-09  4:43 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210308122719.928917471@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=axboe@kernel.dk \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).