Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6986025yba; Thu, 2 May 2019 02:00:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdbOb3dfBeTX6nZKJp4BOyJb8V20zxf349gaGPfhg8G2JEKyJKRH75zFDiiPUFI8xcMIMC X-Received: by 2002:a63:2b41:: with SMTP id r62mr2756875pgr.403.1556787650584; Thu, 02 May 2019 02:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556787650; cv=none; d=google.com; s=arc-20160816; b=VIA5KhP4k8RU2Lojmly7ggLG3vo16LgHsYMi1ZzI+5hjyeu25rY1Ykjo29h58PNyVC V7/0LTYth0fblwPmyjTe1Cjr7rk5274yDQZuhaSHRQLit3k5QQn06GBzYtdNEoP+Rab8 5RRs6RGQGmxzbSElPWQQ0k5QyN1FclY1HBaMKKO61LFedQDpCJM13JMxbD/pJGOqC7aC WHp/2C6J74HFNqRrPHXfI3U6d5/edKJknK8AldXE1YUjs8xNsQUMZgwUSULSwP1b9VDS QuLoAB1EZWmAdOURK9458CMqs6pWXl8MHzBiyDyxQ3c2YwuPSba8HQCnI1IntaJ/3EwS 838g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=wImb9CVB4GpKwFy3KJ9W0eoEvKw0F8sKUcEl8Dq86qE=; b=oPjE8zaDKlFmpogV/emQbj82ToHthW/EIva5uVrws5BwXLChDdgSc4vXNxqT9Y+EWG fhfXGM+vSAleWMuFylcRgJMq3M72O7xmnSNsc91ExGHLdisL5iBVzrEkCkeGBBlEUg/W NS3Nab3sKwBujAE4Cd26kWF3jNMHszKSh5AJrl39XHCIcO7q9cm1bQPHG5L5BDkLV7Pg v3LWwW95z7V7Paev3lvD4EtSY1D/8jnSSkBlKrjZbP7XznOsFmGU8N5hPN2RgBxCoidA 9kQl1uroFEHnydOjecWBHZvCNtCS47ftlsI0PH3u2WlmYDge3JTCELRo/T7krYz8H/Gc cl8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Pe194CRa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si42714904pfc.276.2019.05.02.02.00.35; Thu, 02 May 2019 02:00:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Pe194CRa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726454AbfEBI7l (ORCPT + 99 others); Thu, 2 May 2019 04:59:41 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36692 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbfEBI7j (ORCPT ); Thu, 2 May 2019 04:59:39 -0400 Received: by mail-pl1-f193.google.com with SMTP id w20so723108plq.3 for ; Thu, 02 May 2019 01:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wImb9CVB4GpKwFy3KJ9W0eoEvKw0F8sKUcEl8Dq86qE=; b=Pe194CRa2me3Ghu8Yu/zv3y+hAl4SMpjEVeenRNYgMHMHQcT+CIAECk8cTTi/MXGMb cLc0WWUnGRJ2Xdz7LMrvy0jYgM298w6ByzFtPn1DN0ZHYDJ3EjMLPzaLXobNAXlAbwWH 5wVdgyyR2LoGOzs9//qw7ExIrb/gijuwSpk1iRk7Kl4+w5MUrSAzjSoigSQIk7H1Z6HC Qy3FMAPmCa5DZ5Q/FqKSeYm5AySYILmJ+IQyabQe7Al5oOHfj+uAV+NCrDbWBfBTZQeD prmOOfpQM+fDlRdotLooWaaPLvvai8kirQmdq3YV16fIi6et4pE7QSDKz3n5z2eogtNc Strw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wImb9CVB4GpKwFy3KJ9W0eoEvKw0F8sKUcEl8Dq86qE=; b=Xuqv11f0+R40HdLAo2Qdl1VmynUaXs4NH6Vq21+/7kcNGxNAyH8LsXOOOuBiPYcASc mdS4OHK4Ga4E6DlxpcvlJz5erbW/y0QW+Dx5SSiuIVgmGg3/W3/PFHjiYE+JrxTvPyNx OsNfz5RvZB9vR5cAOyUqSPMMclgUEnnDvhlFV06ZIC+YcE34x2Sq3EkLj0AuMb5d4pjX Y8o0eWrSPz70gCJBjAdUHR0aazOGeF2aq9YOToXHHhE1s4AMHKNTFV+NTPXj4efNKGCA xfZLZ0EsBo2dI/0Ak6X7SNHMJrIlWyvqHZDtf9P22RlpspU4SzqBQ4a3k6YrnpLc6PGO IIjA== X-Gm-Message-State: APjAAAWNcJixW/oAS3ECi2URJAH4kfiz7Jkq/zEsZVfbdBVPTjXb1ggF Q61YFvT6BmAF63ZCDhu0wWo= X-Received: by 2002:a17:902:b20f:: with SMTP id t15mr2501576plr.341.1556787579352; Thu, 02 May 2019 01:59:39 -0700 (PDT) Received: from localhost.localdomain ([240f:34:212d:1:1b24:991b:df50:ea3f]) by smtp.gmail.com with ESMTPSA id z7sm74960831pgh.81.2019.05.02.01.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 May 2019 01:59:38 -0700 (PDT) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Johannes Berg , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 1/4] devcoredump: use memory_read_from_buffer Date: Thu, 2 May 2019 17:59:18 +0900 Message-Id: <1556787561-5113-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556787561-5113-1-git-send-email-akinobu.mita@gmail.com> References: <1556787561-5113-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use memory_read_from_buffer() to simplify devcd_readv(). Cc: Johannes Berg Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/base/devcoredump.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c index f1a3353..3c960a6 100644 --- a/drivers/base/devcoredump.c +++ b/drivers/base/devcoredump.c @@ -164,16 +164,7 @@ static struct class devcd_class = { static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count, void *data, size_t datalen) { - if (offset > datalen) - return -EINVAL; - - if (offset + count > datalen) - count = datalen - offset; - - if (count) - memcpy(buffer, ((u8 *)data) + offset, count); - - return count; + return memory_read_from_buffer(buffer, count, &offset, data, datalen); } static void devcd_freev(void *data) -- 2.7.4