From patchwork Fri May 12 19:00:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9724839 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 67498600CB for ; Fri, 12 May 2017 19:35:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D34D2888A for ; Fri, 12 May 2017 19:35:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 521672888D; Fri, 12 May 2017 19:35:43 +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 E247E2888A for ; Fri, 12 May 2017 19:35:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4AE3D6E71F; Fri, 12 May 2017 19:34:48 +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 5011D6E1EA for ; Fri, 12 May 2017 19:01:39 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id q70so823623lfi.0 for ; Fri, 12 May 2017 12:01:39 -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; bh=4qVkcgJBg9ZRyKlHytnEV5sDhMiiRgmUobwzV011/lk=; b=KK5RCTHfHvTbJTyAFNBV1nTe1wSxBA3ZqCn/i8LhfFmNQgwIbtOwNzPztCQ/akykRP gTMQoY6TrBw9jMQAfMk0xA3Mak0kS5Z/Xq5UkDjzltt9KuWUfiZgtpr5c5Yurc5dr6bw a4leXeNTe2W4jdMorw20G1/UFEritz7WYCBK4HNzbch7XwUsjo7d7R95tbO2V1TB3H7E Ec+ZWoo4CDq9QeGcPGHrYF49znaShiI09pNbSm3cijA3x3ubrjgZSxpxE83OmCUbJJcd aOp1bhyH1InptbriZiWhvguke9FnaZ1+1PodNnC2B9s93xVLvZGaicYxdrJc8Nho7Dif VxFA== 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=4qVkcgJBg9ZRyKlHytnEV5sDhMiiRgmUobwzV011/lk=; b=GgGA2n5ND4Quf/KHFzmMPWV/Oz0z4kremm0GxNWcyl4jHE7/eN0RdMXD9nnjKZchcD W8hVO+5p9jNomrFoUGOgoFCw3pOA0lTYlh+U2z2qPXAin+xMIXpf/UutVCmFKWilARaG rO6dYGCbIoOKEo5Wi+fDb5t4DCTGPYY7ZY2GIhBRfm+LCmOBJ1sfSsE8pH/tIVgHu8l2 VDNf4dzPu1wnFqqThqM61KZjXy7DtYMyxpOJCa0s200Omx3s4IpoRNugn6IzQSO6Wk9n 36z1rw4yWqu5L9izb7848VfLLU4FBqyIN7jLA6YYp3BEwRQo0cTy8nsYrPrgY6xteD+i H8aQ== X-Gm-Message-State: AODbwcD/eJIfWBpcynJYBymwf9jGI98JVEkWNRcBv3wTNtqsBfZFHggM M3riG7yPTQaDDA== X-Received: by 10.25.216.22 with SMTP id p22mr1976166lfg.45.1494615697616; Fri, 12 May 2017 12:01:37 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-91-175.pppoe.spdop.ru. [109.252.91.175]) by smtp.gmail.com with ESMTPSA id f25sm418298ljb.65.2017.05.12.12.01.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 12:01:36 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH 1/3] drm/tegra: Fix lockup on a use of staging API Date: Fri, 12 May 2017 22:00:43 +0300 Message-Id: <20170512190044.17541-1-digetx@gmail.com> X-Mailer: git-send-email 2.12.2 X-Mailman-Approved-At: Fri, 12 May 2017 19:34:31 +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 ab2dfd4e4bd9..768750226452 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -430,18 +430,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) { @@ -585,7 +573,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; @@ -610,7 +598,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; @@ -639,7 +627,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; @@ -664,7 +652,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;