Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp795824ybt; Sat, 13 Jun 2020 23:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy79lSownHZEP2LuCki2j3kgaFUyEOQl2avDSg5AnLnjbzhlY/rpd3Up5HcHGlS2xGS6VQE X-Received: by 2002:a17:906:ae14:: with SMTP id le20mr19837021ejb.307.1592116747178; Sat, 13 Jun 2020 23:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592116747; cv=none; d=google.com; s=arc-20160816; b=xnXkTsMXiWsgW4BAGPTRR6yiLOkxx8ep13Bj/6G3Ej3LDDqkNumUsoACGQLRuFW29F E5x/0kkahlULNOvY+IS7bTGsCvCTSBQifRwuFKfOSNrD3NHdvXZ/BPYZQca06Hu1rhwc WTu7bI7QjHlsIsst+SrF9G00L6z/pPZTUFKh5J9DFWqNKwO+6J4MJOAoKzmeY3HttXmY XGI42HN/heKpdbEkmO7jxkMpHtH3Bm9TgfO2aofgpvTcA2nNHpD5sItNzyZe0znl6zqL STOGisNZEPkJqCx0W60TFYpkfOKq7tmcNPwcfXDjnQmSd9Nt5+8FarlDxrBRFfIUEGBz sgbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=bKaN8g4E8r9fQxgvVd0mPWT0d8FcyExRTIB0iopHs20=; b=hYGPXYPe5kmB7MbjEtxIq0YiA8in4+pqjLfDl7XgNY6qWn2uPfSWyRNl+nGWXjXNNx 9TMpS7PnzXNXofg3L7BfSbpL/hajKlCai41+TR5HNGSRtGlQmah3agOFnx5238YoqsQo XAlOo9MeykFYmtrOQ9E0FTD19kNVU+I+By1Fx2Fmf/5HN4jxxhbLJfwzN7RFZYr65qrP 55jP1JB3FH2SGwyU0uJrlUc9izg4R8RBe7aGokYCRrb41FJ8a8KfwUY0ObA2rIyiwtG2 JlfzzItzQJYR4gFapIAPx53YX4ii7nggXHlU6r5KhUjkvA58EVCZptC4no9aobxj0R5X KLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ETKnsbcx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t18si8129417edt.132.2020.06.13.23.38.43; Sat, 13 Jun 2020 23:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ETKnsbcx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgFNGg1 (ORCPT + 99 others); Sun, 14 Jun 2020 02:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725265AbgFNGg1 (ORCPT ); Sun, 14 Jun 2020 02:36:27 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45448C03E96F for ; Sat, 13 Jun 2020 23:36:27 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id i1so12417168ils.11 for ; Sat, 13 Jun 2020 23:36:27 -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=bKaN8g4E8r9fQxgvVd0mPWT0d8FcyExRTIB0iopHs20=; b=ETKnsbcxF82ikBJ4PWFBq2K917ciwh8HDIPEUR4jCqP85AgzV6s4WH/RHAXPfC1P6G GrYS3YXBuHzLraLGZbqMGqepIdDByQ9///wyrDR4VLOImj9yE22338jOugJpTHxx5LON 5QhkLv+fvqf01Y0qYHwNyFP/N2XqAGcLeU8+Zrwsi2vee32VuF7RNdzrpaGoWnyjedlX NKih70rnvhskUERAyOCiD5OOhJRK+2Eup8tVUNmWenlUSpI+S0gcqh25j5O2VBkzY7AS XnFJU9CCHlzW9k/vYFF0J24lMN9544HKguJtSQywjfUet3Gc89ugtPebwC08VSdPZI/E upiQ== 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=bKaN8g4E8r9fQxgvVd0mPWT0d8FcyExRTIB0iopHs20=; b=F7CPee/15cDRkW4NElddeN9GYZtM54zG0a8n5zs6l+yB34NiwrZZSGu8yxjy1ztAHe ZSbkAb10TWqzv3gSbQOogq+j/u/j5DIx1enNxla24jJgSQp+pa7ZAmV1NmLyTZ5YIxTd FqKkmZayn5i5HYKz/ipuoE1jQzZr6eF9oSohBC9t8JlfPDgd32FA9X88S09WPX3NJud7 0iLA+caX+6MHcSQtMo4JkNWafVuH/lGcq9Ob13cc+kHdUbI3rPN8CIO123EAEdixkWXm ZvOhqg6DojLxpfw/xub8A4wssiqnOwTwakSl8JowZrJ8gj5kc/92mPq3BRu0GAl/nBBL iEZw== X-Gm-Message-State: AOAM533flBUr7MDv8pq1qWbRmIyp0WzRTPlWSHHk0mo4gmK/qDkI1VMY lacwGhqGShs3pHueagCf120= X-Received: by 2002:a92:aa13:: with SMTP id j19mr20877607ili.193.1592116586536; Sat, 13 Jun 2020 23:36:26 -0700 (PDT) Received: from cs-u-kase.dtc.umn.edu (cs-u-kase.cs.umn.edu. [160.94.64.2]) by smtp.googlemail.com with ESMTPSA id r17sm5957131ilc.33.2020.06.13.23.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 23:36:26 -0700 (PDT) From: Navid Emamdoost To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu, mccamant@cs.umn.edu, Navid Emamdoost Subject: [PATCH] drm/panfrost: perfcnt: fix ref count leak in panfrost_perfcnt_enable_locked Date: Sun, 14 Jun 2020 01:36:19 -0500 Message-Id: <20200614063619.44944-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in panfrost_perfcnt_enable_locked, pm_runtime_get_sync is called which increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning. Signed-off-by: Navid Emamdoost --- drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c index 6913578d5aa7..92c64b20eb29 100644 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c @@ -83,11 +83,13 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, ret = pm_runtime_get_sync(pfdev->dev); if (ret < 0) - return ret; + goto err_put_pm; bo = drm_gem_shmem_create(pfdev->ddev, perfcnt->bosize); - if (IS_ERR(bo)) - return PTR_ERR(bo); + if (IS_ERR(bo)) { + ret = PTR_ERR(bo); + goto err_put_pm; + } /* Map the perfcnt buf in the address space attached to file_priv. */ ret = panfrost_gem_open(&bo->base, file_priv); @@ -168,6 +170,8 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, panfrost_gem_close(&bo->base, file_priv); err_put_bo: drm_gem_object_put_unlocked(&bo->base); +err_put_pm: + pm_runtime_put(pfdev->dev); return ret; } -- 2.17.1