From patchwork Fri Oct 31 22:54:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 74FA89FBAB for ; Fri, 31 Oct 2014 23:56:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EFF820160 for ; Fri, 31 Oct 2014 23:56:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 46AA4201B9 for ; Fri, 31 Oct 2014 23:56:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BF1F6E850; Fri, 31 Oct 2014 16:56:33 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 048516E850 for ; Fri, 31 Oct 2014 15:57:31 -0700 (PDT) Received: by mail-pa0-f43.google.com with SMTP id eu11so8609484pac.2 for ; Fri, 31 Oct 2014 15:57:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xnujct/lDTpJWiLS/dbsciFObOK3tXw80EJ0j9X8U7I=; b=hdirc/lfc+DVtXu8oXyJSpRGUGuH3HEGMNxblLw5FdxlZiDse+ZXZquZYMWxpJ9YxR lKCYy8ecdj0ngLdE67wOriXKSMTZjvYpyZ088iyOo6Bz3iyRiVhwQ9zgLEJ0YS52t7ZS p/ZadQ6pfb4WpWZwps4axxZc1uCtyUDjABkPln0opG5/SE2OlLOvLCDx8LlOTk37hB/l Yucst0B3wNuXNQpYn2hwbFvJSQSf+jINM+cmglik/ro2Xel5u1AiITI7xYpe77vUAA7n u1IZLyQDpX3Qkexc8EfiQH05xETAW8TElVeapV9JfPJD4KYQ6i35CcXqtq4uSgjEqdkS wmXg== X-Received: by 10.69.0.138 with SMTP id ay10mr27301656pbd.110.1414796250895; Fri, 31 Oct 2014 15:57:30 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.57.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:30 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 52/72] imx-drm: Reset ipu unit pointers to NULL on errors Date: Fri, 31 Oct 2014 15:54:35 -0700 Message-Id: <1414796095-10107-53-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:32 -0700 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-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the crtc and plane drivers it is possible the ipu unit pointers could be left at error pointer values. Reset them to NULL on errors to prevent this. Also ipu_put_resources() should reset the units to NULL after releasing them. Signed-off-by: Steve Longerbeam --- drivers/staging/imx-drm/ipuv3-crtc.c | 11 +++++++++-- drivers/staging/imx-drm/ipuv3-plane.c | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 423b004..3040f8e 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -375,13 +375,18 @@ dev_put: static void ipu_put_resources(struct ipu_crtc *ipu_crtc) { - if (!IS_ERR_OR_NULL(ipu_crtc->dc)) + if (!IS_ERR_OR_NULL(ipu_crtc->dc)) { ipu_dc_put(ipu_crtc->dc); - if (!IS_ERR_OR_NULL(ipu_crtc->di)) + ipu_crtc->dc = NULL; + } + if (!IS_ERR_OR_NULL(ipu_crtc->di)) { ipu_di_put(ipu_crtc->di); + ipu_crtc->di = NULL; + } if (!IS_ERR_OR_NULL(ipu_crtc->ipu_dev)) { module_put(ipu_crtc->ipu_dev->driver->owner); put_device(ipu_crtc->ipu_dev); + ipu_crtc->ipu_dev = NULL; } } @@ -411,6 +416,7 @@ static int ipu_get_resources(struct ipu_crtc *ipu_crtc, ipu_crtc->di = ipu_di_get(ipu_crtc->ipu, di); if (IS_ERR(ipu_crtc->di)) { ret = PTR_ERR(ipu_crtc->di); + ipu_crtc->di = NULL; goto err_out; } @@ -425,6 +431,7 @@ static int ipu_get_resources(struct ipu_crtc *ipu_crtc, ipu_crtc->dc = ipu_dc_get(ipu_crtc->ipu, ipu_crtc->ch->dc); if (IS_ERR(ipu_crtc->dc)) { ret = PTR_ERR(ipu_crtc->dc); + ipu_crtc->dc = NULL; goto err_out; } diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 76ac178..3a1ebfe 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -285,12 +285,18 @@ void ipu_plane_put_resources(struct ipu_plane *ipu_plane) ipu_plane->irq, ipu_plane); ipu_plane->irq = 0; } - if (!IS_ERR_OR_NULL(ipu_plane->dp)) + if (!IS_ERR_OR_NULL(ipu_plane->dp)) { ipu_dp_put(ipu_plane->dp); - if (!IS_ERR_OR_NULL(ipu_plane->dmfc)) + ipu_plane->dp = NULL; + } + if (!IS_ERR_OR_NULL(ipu_plane->dmfc)) { ipu_dmfc_put(ipu_plane->dmfc); - if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch)) + ipu_plane->dmfc = NULL; + } + if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch)) { ipu_idmac_put(ipu_plane->ipu_ch); + ipu_plane->ipu_ch = NULL; + } } int ipu_plane_get_resources(struct ipu_plane *ipu_plane) @@ -300,6 +306,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane) ipu_plane->ipu_ch = ipu_idmac_get(ipu_plane->ipu, ipu_plane->dma); if (IS_ERR(ipu_plane->ipu_ch)) { ret = PTR_ERR(ipu_plane->ipu_ch); + ipu_plane->ipu_ch = NULL; DRM_ERROR("failed to get idmac channel: %d\n", ret); return ret; } @@ -307,6 +314,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane) ipu_plane->dmfc = ipu_dmfc_get(ipu_plane->ipu, ipu_plane->dma); if (IS_ERR(ipu_plane->dmfc)) { ret = PTR_ERR(ipu_plane->dmfc); + ipu_plane->dmfc = NULL; DRM_ERROR("failed to get dmfc: ret %d\n", ret); goto err_out; } @@ -315,6 +323,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane) ipu_plane->dp = ipu_dp_get(ipu_plane->ipu, ipu_plane->dp_flow); if (IS_ERR(ipu_plane->dp)) { ret = PTR_ERR(ipu_plane->dp); + ipu_plane->dp = NULL; DRM_ERROR("failed to get dp flow: %d\n", ret); goto err_out; }