From patchwork Sat Jun 7 14:55:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 4315611 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 D64629F170 for ; Sat, 7 Jun 2014 14:55:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 040B1201BA for ; Sat, 7 Jun 2014 14:55:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 08D6F2018B for ; Sat, 7 Jun 2014 14:55:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B818D6E30A; Sat, 7 Jun 2014 07:55:45 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f42.google.com (mail-qg0-f42.google.com [209.85.192.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 49F3E6E30A for ; Sat, 7 Jun 2014 07:55:44 -0700 (PDT) Received: by mail-qg0-f42.google.com with SMTP id q107so6933750qgd.1 for ; Sat, 07 Jun 2014 07:55:43 -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:mime-version:content-type :content-transfer-encoding; bh=akWQJ8dpuwIXXnADLOHi+7ubKSLu0IxXdDhslKeDboE=; b=d+23oyrPhXCCrPvHertYfkEiJML6LtCplZfkNQlvjEJ3WuO572S3D1qMlL4eBx8IH8 K0Ng+sgCXU7qGWpOK6IoMjy1Lw3K9j6txSFZ4LZHY2WZCKkcwhCEhfM/M84GxYpjfdoV VnGIAiORFex+ZCUnKceuUikRgCDczkIl6cxQVg46dCjzdN80MvDOE5xeb8LpDROUP1kp 1+dhtL9t/5Y2T4dPIVAyg5c0ZtO9L40uI6d4YRXiAUZtdwQIIpXVreBsQxrrIgjdwzOJ li+NisYWkDEm/4GBqvihvRlKJoXy3vQd7W3Z6azxCyK61+f3eParJuLe4TPSpkDPs1Hh bEjw== X-Received: by 10.140.37.49 with SMTP id q46mr17356406qgq.39.1402152943713; Sat, 07 Jun 2014 07:55:43 -0700 (PDT) Received: from localhost (pool-108-20-252-79.bstnma.east.verizon.net. [108.20.252.79]) by mx.google.com with ESMTPSA id m2sm7898355qga.47.2014.06.07.07.55.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jun 2014 07:55:42 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: fix uninitialized acquire_ctx fields (v2) Date: Sat, 7 Jun 2014 10:55:39 -0400 Message-Id: <1402152939-25485-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.9.3 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=ham 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 The acquire ctx will typically be declared on the stack, which means we could have garbage values for any uninitialized field. In this case, it was triggering WARN_ON()s because 'contended' had garbage value. Go ahead and use memset() to be more future-proof. v2: now with extra brown paper bag Reported-by: Ville Syrjälä Signed-off-by: Rob Clark Reviewed-by: Ville Syrjälä Tested-by: Ville Syrjälä --- drivers/gpu/drm/drm_modeset_lock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c index 7c2497d..0dc57d5 100644 --- a/drivers/gpu/drm/drm_modeset_lock.c +++ b/drivers/gpu/drm/drm_modeset_lock.c @@ -64,6 +64,7 @@ void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx, uint32_t flags) { + memset(ctx, 0, sizeof(*ctx)); ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class); INIT_LIST_HEAD(&ctx->locked); }