Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3694331imm; Tue, 11 Sep 2018 00:02:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/shcAYMhPq5PpPNglc1LWRuQKAH5l9Yc2yRK5hkxYahU/hdUxee/e++RL+Ps0G+zUKaf/ X-Received: by 2002:a63:25c4:: with SMTP id l187-v6mr26651226pgl.29.1536649370625; Tue, 11 Sep 2018 00:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536649370; cv=none; d=google.com; s=arc-20160816; b=V0MPs/h5Adus4EDFwpiz1mki8epFqq/KhvyOrnXSo7iVl6Oa6kHzi9zQ/nIQ3N71if 6t+7nIRdKCmj34lqb8tqBSmBL3Da4coC9ZfFix6Sad2O4U0lZ0PuFho3P2FGYOp2JIKR DaLr+gXIWdb3a/zjkOFLI2OdfLSbSebKQdDTxB4L2wD01Mvf36U5RXetMjwk0ju9gvvu PJ3hd99+d/l9oVzMOqo55jqQbEXw1P9E1aL/33+//SDYR4YCsMDMIRIp51Ugsb4Xe5i3 7Ad4IdZwS1Y3NAIHr6CRIUzTruFzdmFzk3Z07V2dDI4+QSu/nKRPm131jr0Qr0WzgKpC NBHQ== 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; bh=me39Zb2FJrrYMJsxvUM3btz9pmM5AbwwvU1YHmKgzoU=; b=fjuz8SLSin0RqZyNHLkKkmDkxnK0hC2bW1kEM0tzeJWJ90Fp816+IIAY1InIXZuI2G Mjc2uzr+sZ8rZkHX0wGUukn4jlVYCa1F2TmRW9un50DuHrLodbwpOntaTK5s8U6MlsRR zeS/iYxX5dY1oeo6UMF5DAg3KbxetDcdGZaBC4ypwqPG7tN0zinJiYPK8D2iNDPQF4ec l3TpIqrIZ+QiAhQyi0+afhxd2n5WgXD7o0LqKJEz0My4DZ9HqBFG3TOKtrtjx/4F2xs6 R0p4xYN37FfgKjLqgW38d2ilC0Li+P8a486Jzyy+UfdxZsKpppWGqWwQ9W3LFA7kSr4d ubew== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14-v6si19756845plb.230.2018.09.11.00.02.29; Tue, 11 Sep 2018 00:02: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbeIKL5Q (ORCPT + 99 others); Tue, 11 Sep 2018 07:57:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60538 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726301AbeIKL5Q (ORCPT ); Tue, 11 Sep 2018 07:57:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A41A85745; Tue, 11 Sep 2018 06:59:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E3BD63F27; Tue, 11 Sep 2018 06:59:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B902F9B1B; Tue, 11 Sep 2018 08:59:21 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: laurent.pinchart@ideasonboard.com, Gerd Hoffmann , Sumit Semwal , linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK), linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 02/10] udmabuf: improve map_udmabuf error handling Date: Tue, 11 Sep 2018 08:59:13 +0200 Message-Id: <20180911065921.23818-3-kraxel@redhat.com> In-Reply-To: <20180911065921.23818-1-kraxel@redhat.com> References: <20180911065921.23818-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 11 Sep 2018 06:59:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 11 Sep 2018 06:59:24 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reported-by: Laurent Pinchart Signed-off-by: Gerd Hoffmann --- drivers/dma-buf/udmabuf.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index e63d301bcb..19bd918209 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -51,25 +51,24 @@ static struct sg_table *map_udmabuf(struct dma_buf_attachment *at, { struct udmabuf *ubuf = at->dmabuf->priv; struct sg_table *sg; + int ret; sg = kzalloc(sizeof(*sg), GFP_KERNEL); if (!sg) - goto err1; - if (sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->pagecount, - 0, ubuf->pagecount << PAGE_SHIFT, - GFP_KERNEL) < 0) - goto err2; + return ERR_PTR(-ENOMEM); + ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->pagecount, + 0, ubuf->pagecount << PAGE_SHIFT, + GFP_KERNEL); + if (ret < 0) + goto err; if (!dma_map_sg(at->dev, sg->sgl, sg->nents, direction)) - goto err3; - + goto err; return sg; -err3: +err: sg_free_table(sg); -err2: kfree(sg); -err1: - return ERR_PTR(-ENOMEM); + return ERR_PTR(ret); } static void unmap_udmabuf(struct dma_buf_attachment *at, -- 2.9.3