From patchwork Tue May 23 00:14:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9741633 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 8623B60388 for ; Tue, 23 May 2017 00:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4E2286EC for ; Tue, 23 May 2017 00:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7039128779; Tue, 23 May 2017 00:59:56 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 F1F38286EC for ; Tue, 23 May 2017 00:59:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F333D6E2DB; Tue, 23 May 2017 00:59:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2B9D89C49 for ; Tue, 23 May 2017 00:15:17 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id 99so6669442lfu.2 for ; Mon, 22 May 2017 17:15:17 -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 :in-reply-to:references; bh=/1Ai3F1hGUI+rshgJJnzFcUYBNazYiXKBIZhiZeM9+I=; b=q1SfR7YJa9IoR+RfLos2KA+m32389/cHbcZe79kdcZyZJqqH+u48SFqs5xNymd0u/x FVNWLu13fOEhF4QG8MbQBjyr0Vff9zEWoypbK6iW9wDkmvfcOcWK3JZWnDx38inL1QoU BVIrioeI4TFSS5qR6zPQIZ4b4B0Reo1zIg0Z+CLRaIm/REkm6fBLsmdKQe9lJVhAbqIg qBm2vnk7CS/w++flIh9ox+2yKlFdFprVq/jsCv9KhSv1JoNK6IN2CLDcGf6d/kea6+tp FQ8Ow8leRlX6xmym0JvmzTa+FEG8EKT9pHZFZqAgDB4LdF/h6gMY2QduwS1Ri4WAMj1Z jDcg== 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:in-reply-to:references; bh=/1Ai3F1hGUI+rshgJJnzFcUYBNazYiXKBIZhiZeM9+I=; b=hHbSB4mVqM3YTc4m3boE1J19MrZcZ/C2GWUoCBL+1kmw89rSMT5yOQ7LPclTfSdfSE zqj/79ChfsyA7vtPfdKqhXSDQRavGcmRHhe8EVjMzK6/6A4yWdUr5e+VwDOvtFB0Im+S Z4FzvYvVqP1x8J5lAoFYLo/pL9pEcCj7ph3kEQsE0CqB4fCqiFC/Jvivnqh4YXaAMi/y 1G+C/qUEUXyJNhItxq44EaGtvTsOGS0GEKqNw26ORqdn43oHkH2UDiLSTOiy+srqmTsF AF19UgJ5UnO58rJZlnja2jSzypsadjKGGp/7k01honOicCQ5sCtHxegCb4KlwymzYrS8 +/dQ== X-Gm-Message-State: AODbwcALKdX+3rDDyWv36iZdDcp35CLZKO5Shm5s25AFXMgbAyGxjQ6T ZI6wV5uacEmHLQ== X-Received: by 10.25.33.8 with SMTP id h8mr6787335lfh.132.1495498516149; Mon, 22 May 2017 17:15:16 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-175.pppoe.spdop.ru. [109.252.91.175]) by smtp.gmail.com with ESMTPSA id v30sm3440904ljd.9.2017.05.22.17.15.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 17:15:14 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Mikko Perttunen Subject: [PATCH 01/22] drm/tegra: Fix lockup on a use of staging API Date: Tue, 23 May 2017 03:14:16 +0300 Message-Id: <1f58132d9a6580a74e78b30d567fb2c874466def.1495498184.git.digetx@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Tue, 23 May 2017 00:59:38 +0000 Cc: linux-tegra@vger.kernel.org, DRI Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit bdd2f9cd ("Don't leak kernel pointer to userspace") added a mutex around staging IOCTL's, some of those mutexes are taken twice. Fixes: bdd2f9cd10eb ("drm/tegra: Don't leak kernel pointer to userspace") Signed-off-by: Dmitry Osipenko Reviewed-by: Mikko Perttunen --- drivers/gpu/drm/tegra/drm.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 51c48a8e00ec..b49d32a89f40 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -451,18 +451,6 @@ int tegra_drm_submit(struct tegra_drm_context *context, #ifdef CONFIG_DRM_TEGRA_STAGING -static struct tegra_drm_context * -tegra_drm_file_get_context(struct tegra_drm_file *file, u32 id) -{ - struct tegra_drm_context *context; - - mutex_lock(&file->lock); - context = idr_find(&file->contexts, id); - mutex_unlock(&file->lock); - - return context; -} - static int tegra_gem_create(struct drm_device *drm, void *data, struct drm_file *file) { @@ -606,7 +594,7 @@ static int tegra_close_channel(struct drm_device *drm, void *data, mutex_lock(&fpriv->lock); - context = tegra_drm_file_get_context(fpriv, args->context); + context = idr_find(&fpriv->contexts, args->context); if (!context) { err = -EINVAL; goto unlock; @@ -631,7 +619,7 @@ static int tegra_get_syncpt(struct drm_device *drm, void *data, mutex_lock(&fpriv->lock); - context = tegra_drm_file_get_context(fpriv, args->context); + context = idr_find(&fpriv->contexts, args->context); if (!context) { err = -ENODEV; goto unlock; @@ -660,7 +648,7 @@ static int tegra_submit(struct drm_device *drm, void *data, mutex_lock(&fpriv->lock); - context = tegra_drm_file_get_context(fpriv, args->context); + context = idr_find(&fpriv->contexts, args->context); if (!context) { err = -ENODEV; goto unlock; @@ -685,7 +673,7 @@ static int tegra_get_syncpt_base(struct drm_device *drm, void *data, mutex_lock(&fpriv->lock); - context = tegra_drm_file_get_context(fpriv, args->context); + context = idr_find(&fpriv->contexts, args->context); if (!context) { err = -ENODEV; goto unlock;