From patchwork Thu Apr 25 15:48:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10917395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 146ED912 for ; Thu, 25 Apr 2019 15:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B5428ACB for ; Thu, 25 Apr 2019 15:49:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E687028BFE; Thu, 25 Apr 2019 15:49:22 +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 89FFB28ACB for ; Thu, 25 Apr 2019 15:49:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1589891CB; Thu, 25 Apr 2019 15:49:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 209BE891CB for ; Thu, 25 Apr 2019 15:49:20 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id t17so49069wrw.13 for ; Thu, 25 Apr 2019 08:49: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:mime-version :content-transfer-encoding; bh=plb2DK8eqv+Q6V4kXOP66ZhwVPZQEVRXNQ5aVuKbpbI=; b=Xr1lT4IgaSLyBRMlZOQgaOMyHqaLEipNnG+Lyj8tVgpsrzbE3GjR6nTrbim1rW54iy lOUN3ayCtk6mI2YvASnBOG+6MxqsF68aNvj3j45HKHfbsGKzD4KbQCr5xfcdtKgEH2T9 dQC0k8/StJSQ7F0xDFN+GmJ6ZaUb8bb5ZSoZH9EmGGXFKhBwqDlSJy3EkJq20xxwuBmu FLjHPUGRNWGmPD/4+yWv9p+Wqh+4gmksQeJVwBN3tqG9tUg+AtqMSa4tquLhGYEsZk9L Ra3fkLySekCU9nWZOMzIzjjFVfc/n6YWs0uIDUYcxAwhdy0IW28cly9laxTDOBOnuDqY K9nQ== X-Gm-Message-State: APjAAAUPI9CPoQ3LaS9cFdbf11IKvLo/RYK2zwrUFO6iBpXLWlIP9MMI 3uPr+2XKrx3gwEAVM2qJ6YxNYRxS X-Google-Smtp-Source: APXvYqzPpRGeFUOOvJ79VQJz/bVyLzNCVLzY/kT/LadvE2hw/ZPsY56f75WLtqcvFy0DeuA4PDpHpQ== X-Received: by 2002:adf:db0c:: with SMTP id s12mr27615234wri.184.1556207358503; Thu, 25 Apr 2019 08:49:18 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id q7sm7652717wmc.11.2019.04.25.08.49.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 08:49:17 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH] dma-buf: call kfree() w/o mutex held in dma_buf_attach() Date: Thu, 25 Apr 2019 16:48:50 +0100 Message-Id: <20190425154850.32740-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=plb2DK8eqv+Q6V4kXOP66ZhwVPZQEVRXNQ5aVuKbpbI=; b=Wau4zjvkvVBhy5IXBt4McWJUUwXxENri2/jDppxybK7ubYkN5+wRkJ+M43I3Bf4tEW nP10qGJqM+W+sESLWz5BtsyZV2rKNCud9zeRM+4RMlOV9qNmRU7C1TQmj5Jxp8s1ETvl GoeeUp6gR0Vqx0NagI0mvrg+tE5eQUEIlQAKKNtnVsjGqiRkYeGoyyU6zha33ToC2xP0 gF+jhX6vOz/4M2Z1kA2AWRmBpSLXp4Y7ki7ztITrD4hDGEKNUTqlyI/QTEwrYdeLyz5k OOUJtfLhb8C7slKIOYtKzqATR+o0RkMADbs2GSLI1SoxNq0N64N/MNwL0mZwGLihSUrJ RqPA== 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: emil.l.velikov@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov In dma_buf_attach() we allocate memory w/o a mutex being held, thus in the error path we should kfree() it after the mutex_unlock. The inverse function dma_buf_deattach() gets this right. Cc: Sumit Semwal Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 3ae6c0c2cc02..57ddeb735b8b 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -579,8 +579,8 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, return attach; err_attach: - kfree(attach); mutex_unlock(&dmabuf->lock); + kfree(attach); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(dma_buf_attach);