Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1708800pxb; Mon, 8 Mar 2021 04:35:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxH+6OgQHipxCcT5vppd3ENVwUnCHj/yCVoOjyXd2VnjBKbAqiaqv4Nzcr7uMsYVERX4+Rz X-Received: by 2002:a17:907:75c2:: with SMTP id jl2mr15090605ejc.334.1615206955869; Mon, 08 Mar 2021 04:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615206955; cv=none; d=google.com; s=arc-20160816; b=DF/F1UIi66v263xVQDNpaLkg1J+HoSGWl1PzBdijkCxcg5TUPOdpTh8aGnhC+tLbjt z9xO3d6II7mPyh3QWyEiwywq9HbWgrAmVNLVXvyyuMWa0akFRa4MzZ49e3ZGkIZEo7md owVKq5dQWtcXVUnneIF8+WxBZmq5HRlmcM20yTDk58Pih+FhKQ8/BZ17x+1dC42O/r6P xcW6n+aLHiUBsPfdxFeYjW9aKKN3qyLU/o4pwq/ApPHZWa8P4928COCSd8C0PPwaK9Y0 HXt03y/1bijrLDYyrO7Bj9++koWv2tNX0+QAw8a7fmIQWeNSll/n2/q6JR1f6XTbobnX B2ww== 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=mRGm8ihkV1rxd1dsAYPGIKkNWNHUglpaetxs1T2z1Vc=; b=sR9oEqe46HjJ0uR6uZ4WMge7kBqySNtU4uiAAMz/t8+I6SKCsvVbAeU60rcyaS382e mNJy6tbMn24Rz/3gRaGqnLCwLGA2E+1XXJLnegToSpIhC6fPqTF/JRI3qDVvIy3woAAs If/XnYLbQz0mQw3+P5zxm/vmXT66CKv5811RGRBbnHl1cN6TujKcXhEjKfWC5/kPfhw9 F5ijvsAt4lrv7wR0TILN1ekRflF92mq6ljcAB1mb8sbv5IgmdLjn2NrPPsH6JgTI312X 5XoIS6BjAHR4YsbFN4isz2U5Wd36b72pdidGeNl2jfP7xLSWOteE4S/0WO/AT1m78Hjb sxsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B99Jrap9; 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 cm2si6664160edb.549.2021.03.08.04.35.33; Mon, 08 Mar 2021 04:35:55 -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=B99Jrap9; 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 S232017AbhCHMcX (ORCPT + 99 others); Mon, 8 Mar 2021 07:32:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:41008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbhCHMby (ORCPT ); Mon, 8 Mar 2021 07:31:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF45C651D3; Mon, 8 Mar 2021 12:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206714; bh=KsUzA5GS3Dks1R2FGSaF9xRXp9SszcEGq5jm5DJKKdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B99Jrap9X3LERxYsgiYYpHIQ5HCUEl8dR9SZbZr4gzDRdlMjUntU81zXpONGBJqkL RvYINicFIXmEbh15EkUSMBnf7WlEkvXUdYMpxMM0O9B0HT0uWtuHy76WNfp6FBT+4x HJmExzOzq5FFoOT0Wpo8Din/BqDHfkUIWmDjvqrA= 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.4 21/22] rsxx: Return -EFAULT if copy_to_user() fails Date: Mon, 8 Mar 2021 13:30:38 +0100 Message-Id: <20210308122715.424235770@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122714.391917404@linuxfoundation.org> References: <20210308122714.391917404@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 10f6368117d8..804d28faa97b 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