From patchwork Fri Jan 24 09:31:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 232855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64100C2D0DB for ; Fri, 24 Jan 2020 11:37:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31A522467B for ; Fri, 24 Jan 2020 11:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865873; bh=w8I3q/H8D+xz74nVtTtd2Hsj1Psua0C3tPm6m8HhW4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=do3sFl9qyH8THCsaI1o4M09puPruKDdUuiwecsYMulDjX//8feZLeWrifz2igu4YT 19QCioRi6WhtKnKPyVovudX36f6S0LSGC8PLEXfNmwgfD56E+RdBoeEGysZrbShk0w Il5+cVi3iJTdMlsIK7oNW2GNppIrafsfK9maKNdA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404163AbgAXLaD (ORCPT ); Fri, 24 Jan 2020 06:30:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:47514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404162AbgAXLaD (ORCPT ); Fri, 24 Jan 2020 06:30:03 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5F7B206D4; Fri, 24 Jan 2020 11:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865402; bh=w8I3q/H8D+xz74nVtTtd2Hsj1Psua0C3tPm6m8HhW4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yr0DUTRveu9vXgwxTtEe0BHkIop5MdqVynyMveh7C29WO2EpHInooFky8+IJBRCW1 72E0T5UcTc/evJ2m5SAQ01Te/gWyN2qsh5r4eYXTCANlXFmmFgXirwB74kbtcwy0Un MOB/2Uw/pqgnFSYujX67zGg5D80m1bfHd90YQhCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 536/639] bcache: Fix an error code in bch_dump_read() Date: Fri, 24 Jan 2020 10:31:46 +0100 Message-Id: <20200124093156.146001293@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit d66c9920c0cf984cf99cab5036fd5f3a1b7fba46 ] The copy_to_user() function returns the number of bytes remaining to be copied, but the intention here was to return -EFAULT if the copy fails. Fixes: cafe56359144 ("bcache: A block layer cache") Signed-off-by: Dan Carpenter Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8c53d874ada4a..f6b60d5908f70 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -178,10 +178,9 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf, while (size) { struct keybuf_key *w; unsigned int bytes = min(i->bytes, size); - int err = copy_to_user(buf, i->buf, bytes); - if (err) - return err; + if (copy_to_user(buf, i->buf, bytes)) + return -EFAULT; ret += bytes; buf += bytes;