From mboxrd@z Thu Jan 1 00:00:00 1970 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=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 ABF6BC433E0 for ; Tue, 30 Jun 2020 07:44:22 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80F3A20809 for ; Tue, 30 Jun 2020 07:44:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZsDNRiEK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80F3A20809 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6613E88437; Tue, 30 Jun 2020 07:44:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G8kPQc7ze3er; Tue, 30 Jun 2020 07:44:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id CF2618843A; Tue, 30 Jun 2020 07:44:21 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 66FE71BF29A for ; Tue, 30 Jun 2020 07:44:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 63DA086D22 for ; Tue, 30 Jun 2020 07:44:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hMkEjOkal6tv for ; Tue, 30 Jun 2020 07:44:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DBA7286935 for ; Tue, 30 Jun 2020 07:44:19 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id gc15so1686521pjb.0 for ; Tue, 30 Jun 2020 00:44:19 -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=oOqmjhvuPBAEiyHp7TL6kqUg9v7jBR3QwTJJwMLLxHI=; b=ZsDNRiEKrC4VHDYEKtee+J3noCJYUeVzePIO7GhImTxDvwPvsL291zvooNL/qm6jx7 qnvsqFrrr0H9ihS1Is66bjEEHeG61sx8gZXf4AR63LdcMvlVMWz70K1HcmorWTDmY3pP TZhk1IU+7I3ifHtGRczUy13jzXO2ePWyUmxA5hMxDowgt3qR/Z4ORHblGjrLbrC5L5ee U+9wphIvfpa45jM7lc/FtHUy6WxuPiAeZE9+AxZdhLq9JI3WerBztmKQ1ZG3dycI5ezF v5Oo6JytqtOLuwLLnWK5+PDUVYoNkLTPb6z7rWPGFrWO7BAgOntchsftSa2mZkihgAwV zDzg== 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=oOqmjhvuPBAEiyHp7TL6kqUg9v7jBR3QwTJJwMLLxHI=; b=r7u7TtoduFeo6YtAUM8PJ9DWmoh0cOcvlwDSQLCO7+XhwMWNzKFKKjE7sXUgtyY8eA /9dDwU5qXoSaqfUEFYKlIaJkza3LQyffK5Eti76CN8WR4bFkiVBHEqRkjolnm/UE6YSB IdQ2FFJa1Y9hpIyobljcmtwNXuDxvFQCvhohVuRUgtFEbI4EaXITqkDxjWdcRCgo28Z6 tvbbVU7AAdH4H9VHwqP2IInJ4UQ83Dzw+bVNMuZwZqR3aEP6U2T+XPvZhjEJqvKEo3Nu cU1eAXm7faKBhWrCCjFbuwmf4COoalm6gzY20DBYKqXuWeTs9vXqslVPU/lSPe23cge/ yiVw== X-Gm-Message-State: AOAM530GslEGIQ+3HW6Qjv5NpX73wvUsR3gc0dFTgQCusfLlTW3GPY0i o54py8KAh/aCVJvb12RsfBk= X-Google-Smtp-Source: ABdhPJx+RRpJReS8kxqO754KZ2IlBwIUOUaGkjouPlErmio0TT+zq3yenb0xAzezXeGRpVtKb+gcjQ== X-Received: by 2002:a17:90b:1497:: with SMTP id js23mr21624060pjb.30.1593503059495; Tue, 30 Jun 2020 00:44:19 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.182.225.143]) by smtp.gmail.com with ESMTPSA id w1sm1754276pfq.53.2020.06.30.00.44.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2020 00:44:18 -0700 (PDT) From: Souptick Joarder To: jane.pnx9@gmail.com, ldufour@linux.ibm.com, gregkh@linuxfoundation.org, harshjain32@gmail.com, pakki001@umn.edu Subject: [PATCH v2 1/4] staging: kpc2000: kpc_dma: Unpin partial pinned pages Date: Tue, 30 Jun 2020 13:22:16 +0530 Message-Id: <1593503539-18649-2-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1593503539-18649-1-git-send-email-jrdr.linux@gmail.com> References: <1593503539-18649-1-git-send-email-jrdr.linux@gmail.com> X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Bharath Vedartham , John Hubbard , linux-kernel@vger.kernel.org, Souptick Joarder , Dan Carpenter MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" There is a bug, when get_user_pages() failed but partially pinned pages are not unpinned and positive numbers are returned instead of -ERRNO. Fixed it. Also, int is more appropriate type for rv. Changed it. Signed-off-by: Souptick Joarder Cc: John Hubbard Cc: Dan Carpenter Cc: Bharath Vedartham --- drivers/staging/kpc2000/kpc_dma/fileops.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 8975346..becdb41 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -35,7 +35,7 @@ static int kpc_dma_transfer(struct dev_private_data *priv, unsigned long iov_base, size_t iov_len) { unsigned int i = 0; - long rv = 0; + int rv = 0; struct kpc_dma_device *ldev; struct aio_cb_data *acd; DECLARE_COMPLETION_ONSTACK(done); @@ -79,14 +79,14 @@ static int kpc_dma_transfer(struct dev_private_data *priv, rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL); mmap_read_unlock(current->mm); /* release the semaphore */ if (rv != acd->page_count) { - dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%ld)\n", rv); + dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%d)\n", rv); goto err_get_user_pages; } // Allocate and setup the sg_table (scatterlist entries) rv = sg_alloc_table_from_pages(&acd->sgt, acd->user_pages, acd->page_count, iov_base & (PAGE_SIZE - 1), iov_len, GFP_KERNEL); if (rv) { - dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%ld)\n", rv); + dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%d)\n", rv); goto err_alloc_sg_table; } @@ -193,10 +193,15 @@ static int kpc_dma_transfer(struct dev_private_data *priv, put_page(acd->user_pages[i]); err_get_user_pages: + if (rv > 0) { + for (i = 0; i < rv; i++) + put_pages(acd->user_pages[i]); + rv = -EFAULT; + } kfree(acd->user_pages); err_alloc_userpages: kfree(acd); - dev_dbg(&priv->ldev->pldev->dev, "%s returning with error %ld\n", __func__, rv); + dev_dbg(&priv->ldev->pldev->dev, "%s returning with error %d\n", __func__, rv); return rv; } -- 1.9.1 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel