From patchwork Fri Jun 14 22:13:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2725201 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0AC26C0AB1 for ; Fri, 14 Jun 2013 22:14:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 226D120303 for ; Fri, 14 Jun 2013 22:14:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4DB8E202F9 for ; Fri, 14 Jun 2013 22:14:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6025EE5CDE for ; Fri, 14 Jun 2013 15:14:30 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45]) by gabe.freedesktop.org (Postfix) with ESMTP id ECC51E5C11 for ; Fri, 14 Jun 2013 15:13:24 -0700 (PDT) Received: by mail-ee0-f45.google.com with SMTP id c1so625307eek.32 for ; Fri, 14 Jun 2013 15:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=hpzpmByWg/Is2Jozjb7dROTb8q1y6GWjjMAj+mz1jxY=; b=bcoSRrpsv0dQ4KBlnF1g402l7Gu/tnXWpb2nuelNlPFCtJe6Eht4gYam/421Jw5ull Nb79+gBDxo1caZ9AnhI2zt4sclY9KLfbBmU3jt/SsMHbFWFbmjM1fQpDodtbRp9LtPuj l5h7W1dHUlIdFiQO1jh89yIS633Ky2Hk52jPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=hpzpmByWg/Is2Jozjb7dROTb8q1y6GWjjMAj+mz1jxY=; b=RNjM6xITuMQJcwV+pPpnX3ZefDrO3XSzhAB2CbmmQikjduXtFgB7j+mEaDk3TuhrX+ hMkPO9eYDcIKIBqi7Bu5kPyvdKXIs1cMt/80N1+gcGe0Uwfu366T4BPBHfSDUjHXjpQT jmRtsc8yJlYbZYg5rgEtC2DkdGL//lOyj2BMPr+D4naYdKOdxXNdc/Es338Cy1vKHJgD SXpYbb0CSuQzXSNYC63qWYtaGRzW1AF5tWcvak2G/NgMo34fZTJonnhxkeLS5wQWBrfs VRPbbzAEZajFm8mdhRNGd6uRDyjVZajiClJlVL97HE9ZF+854wlaJgQ0Q3Nx7bN0tq4x clOQ== X-Received: by 10.15.52.5 with SMTP id o5mr5302451eew.58.1371248003920; Fri, 14 Jun 2013 15:13:23 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id m1sm6258301eex.17.2013.06.14.15.13.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 15:13:23 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 1/6] drm/crtc-helpers: Enforce sane set_config api Date: Sat, 15 Jun 2013 00:13:11 +0200 Message-Id: <1371247996-6052-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371247996-6052-1-git-send-email-daniel.vetter@ffwll.ch> References: <1371247996-6052-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQnFNMO+/Q9WrPHGyLK3ADPlJF+EhFOzyZERZPnQe5jX84UuL6Gx9lKKXdWFob0j10fJqHRQ Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 There's no point in trying to clean up after driver-bugs, so just blow up. Furthermore it's an interface abuse to set no mode but have an fb and aslo to try to set an fb without enough connectors. These two spefici cases of interface abuse have been committed by the fb helper, but that's been fixed meanwhile in commit 7e53f3a423146745a4e4bb93362d488dfad502a8 Author: Daniel Vetter Date: Mon Jan 21 10:52:17 2013 +0100 drm/fb-helper: fixup set_config semantics The i915 driver has been shipping since a while with these BUGs with no reports, so should be save. Note that this drops an ugly case where we clear crtc->fb behind the upper levels back and so cause a refcounting mayhem, which Russell Kins spotted while trying to hunt down a drm framebuffer leak. Reported-by: Russell King Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_crtc_helper.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index f554516..e57cfec 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -565,14 +565,13 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) DRM_DEBUG_KMS("\n"); - if (!set) - return -EINVAL; + BUG_ON(!set); + BUG_ON(!set->crtc); + BUG_ON(!set->crtc->helper_private); - if (!set->crtc) - return -EINVAL; - - if (!set->crtc->helper_private) - return -EINVAL; + /* Enforce sane interface api - has been abused by the fb helper. */ + BUG_ON(!set->mode && set->fb); + BUG_ON(set->fb && set->num_connectors == 0); crtc_funcs = set->crtc->helper_private;