Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1709433pxb; Mon, 8 Mar 2021 04:36:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv43PmuA+HKusmGA6zqxhnZ765Zs/w56Fw9QbSksq5OrawgPiWUESxAIGJhWJL79AbAenm X-Received: by 2002:a17:907:2b03:: with SMTP id gc3mr14911292ejc.448.1615207004041; Mon, 08 Mar 2021 04:36:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615207004; cv=none; d=google.com; s=arc-20160816; b=C4uCHw6khYr7L0MBn5cZOws0zBNCPNedd225jayWcu//xB8sahkJm1juOnPYPRajQX ITVqpwWKCrEFKf0XbulGHQ6SO69VqeucSx62dYH2muVyBim2uTmK1dsm4dyVOKLtFNZA ijJNGrBG18btx8LILHoNpAXDPdmt1DgNe7JefkJVT3VTyKE49nEQLXBCKpUdTBRS4FZ+ 9PID9WS5uoQmwe27uvR4Uxp/ZI6bx2BfsYHNEISwr6KLtlqCF1nbbLnVc4uD4fiYUeb5 AhMdgWimb+QMQ4i9GQ2iC9jGrEtAICPglNDI+WnFO9ebLqGfm3esVQv8Swnv/JqCB+p+ TUWA== 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=a0O2TwXkbZ1c5kQBSawbk52nLil8I1FUyQfWKmUWVaQ=; b=YBwvyPz5B6YtwNxg/QmF7kbAqXm4ErOwCaZZRMewuVRtLZbtvhTMq66qdY2lO1MiIW KblvE5jSiR2nEiHoQApwhXmcIvAWYREQloz5WcopnNot1vdoPXnHJFMmbglpmEZMu6sW jQAVxza4Q2j3eWErZpF2EVjq0lCTnQbDadJxuqCWZgQBl6zMfrterjAjAWcbmhnTX3FP M8Kd3oOfDD3fD5ofLgMDLVw3SDkLQ1jbiq5KBD5QJ7U6T7zL6Sw4r1fpcCnFslk8NWSR Xj/urI7J6L191VZiGBM7aqcN+Sni6A0ImmzpY1evQQI/PhxCKnYzbxCB3/YIHm/Ad14l dBGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EgOkVd8V; 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 w11si7353981ede.449.2021.03.08.04.36.20; Mon, 08 Mar 2021 04:36:44 -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=EgOkVd8V; 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 S232107AbhCHMfL (ORCPT + 99 others); Mon, 8 Mar 2021 07:35:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:43498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhCHMej (ORCPT ); Mon, 8 Mar 2021 07:34:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76D76651C3; Mon, 8 Mar 2021 12:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206879; bh=0XrOwaHgvfjbL088LeHoqB7jc9U+zNxCKkws2sLNpzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgOkVd8V6bS1uMI/u2Usjw276LF6tMzHBhGHHnYh/LHvZWhtir9rc+aCC2D5Qf7+L p1Pxt/RewNxPwafxezTGFhWbEaiq21brIyqLcAI01SE+rwSiAiDsNZb2R0o4NwBBR4 /466M25HVHHuM22LYk7FFQqniFPCSyaaqZpUi/xQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 37/42] rsxx: Return -EFAULT if copy_to_user() fails Date: Mon, 8 Mar 2021 13:31:03 +0100 Message-Id: <20210308122719.928917471@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122718.120213856@linuxfoundation.org> References: <20210308122718.120213856@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: 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 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