From patchwork Mon Jun 18 06:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 10469437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 549E46032A for ; Mon, 18 Jun 2018 06:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E8D2880F for ; Mon, 18 Jun 2018 06:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37A4D28818; Mon, 18 Jun 2018 06:07:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 453762881A for ; Mon, 18 Jun 2018 06:07:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C63C16E137; Mon, 18 Jun 2018 06:07:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E2686E132 for ; Mon, 18 Jun 2018 06:07:20 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id t2-v6so16359375lfd.6 for ; Sun, 17 Jun 2018 23:07:20 -0700 (PDT) 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; bh=TYdgGtAUZgdonklPmw9db3u5DotkG5GQ4FXvZy0fcaU=; b=S2RnMDCHWSK6iS8ppuRswGeNvF4dHY4Snj6DiT70QmTm4RNAfJEJgkITfTozcX421B 5/725tjNvBjhOGW1zJ9Wv/bO6VWHbK7sYEgg6yRMqWvupEr8S9OWMwK6eJxNUxUew7C9 2JmB7kOrJ2uxt8GBGBh30pGslLWldJt5yMn16gcrQVVs6K4LTViBknHNFylwUJ6mwnIc LEjBCdPOd9sOeWhHdo7GjwbTj/nZMt7MOA3qBxhbrXLh+wBV6RYAQDh9TaSEAyRsjzpf CVyDgVDLBghR5mslbLEq69QclnjkV5kaxq7yb0oZ7qSXSW0POux65qwarjK6C7uipJHK QCDw== X-Gm-Message-State: APt69E0NnDBouzDIKmgMlPYt0sHQ8QatZ2xhwAP/O313lmNTfzBlqb1H C/Nbw7/xXNJyfhcvN/LE6y0= X-Google-Smtp-Source: ADUXVKLnzyTJW6OKQgjnKJwGaahH37KoBRalm2pjw6d4KIKgugpl8ll1l4p8OPAY/RhMHVmrPm4L1g== X-Received: by 2002:a19:f03:: with SMTP id e3-v6mr4137607lfi.83.1529302038711; Sun, 17 Jun 2018 23:07:18 -0700 (PDT) Received: from a2k-HP-ProDesk-600-G2-SFF.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id c74-v6sm2627134lfh.78.2018.06.17.23.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 23:07:17 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, jgross@suse.com, boris.ostrovsky@oracle.com, dan.carpenter@oracle.com Subject: [PATCH v2] drm: Replace NULL with error value in drm_prime_pages_to_sg Date: Mon, 18 Jun 2018 09:07:09 +0300 Message-Id: <20180618060709.14290-1-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andr2000@gmail.com, Oleksandr Andrushchenko MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Andrushchenko Dan Carpenter has reported that there is the following static checker warning: drivers/gpu/drm/drm_prime.c:317 drm_gem_map_dma_buf() warn: 'sgt' can also be NULL 314 sgt = obj->dev->driver->gem_prime_get_sg_table(obj); 315 316 if (!IS_ERR(sgt)) { 317 if (!dma_map_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir, Problematic functions are xen_drm_front_gem_get_sg_table and drm_gem_cma_prime_get_sg_table. Fix those by replacing NULL with error value. Signed-off-by: Oleksandr Andrushchenko Reported-by: Dan Carpenter --- drivers/gpu/drm/drm_gem_cma_helper.c | 2 +- drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 80a5115c3846..ce868ce288fb 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -436,7 +436,7 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj) sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); if (!sgt) - return NULL; + return ERR_PTR(-ENOMEM); ret = dma_get_sgtable(obj->dev->dev, sgt, cma_obj->vaddr, cma_obj->paddr, obj->size); diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index c85bfe7571cb..47ff019d3aef 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -179,7 +179,7 @@ struct sg_table *xen_drm_front_gem_get_sg_table(struct drm_gem_object *gem_obj) struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); if (!xen_obj->pages) - return NULL; + return ERR_PTR(-ENOMEM); return drm_prime_pages_to_sg(xen_obj->pages, xen_obj->num_pages); }