From patchwork Tue May 28 08:27:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 165257 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp8169333ili; Tue, 28 May 2019 01:29:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL2u0tSF9gVids+d9oYUsZ3HfTQTCU6LqI3zB5qe9huV2Y1CEpHl7XDrPvYbl4ASx+wbZM X-Received: by 2002:a63:2ace:: with SMTP id q197mr45278953pgq.102.1559032144781; Tue, 28 May 2019 01:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559032144; cv=none; d=google.com; s=arc-20160816; b=Xp27Dp1NC1vh29TlX+CTGQSY3O+j2OPnTNbMjtGJoWtyRI3nr8sTmS+HonyD3f7khY 07dKw8qnKvwBz+6oH/Mx9NhLe6mgzuAJTRFxvPM+CBTGq4ZyJgTYtPMVgJIrYJANjCNH 89mEmYB5XZzydR2i+9/OO75lAw50e5KcO6KDcWtqwQ8FattIRfQvaomVTf04F4iqGvCP QvArNM72+Uaf09TtVVjkrOZz0LkDZjOPrO2YSyOUjI0z1yoYxOVKtWkhWiqe7EqGC3Iq pb6fuXt8utny8obnh+wjeSSnI4z+C+Y/7KBdJrktBZUdNo7YP0VfzulA2TRfwPmHqnea h2Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=iLtR8QTjYpDNYYZOjj6mmJcL7j06sI7o060cpKsWZfY=; b=rG4JzQ5ERQ8BG37yTATQiKBLVe5e6wx4A6amVawIFS7Pe8e8Jq7bNfAkdKsf5Bz33t egcmRRv0MzDgOLNGJtKWFKWpov3XOFtSaXTELFtzcp68QgHqQZ3mgilrh2xf3J3P8p72 9Ey/3vTGacdZ9mpoJPxH8k8oOPscIrdkxNqf5e7JKBQv9i90jaTfDSK8itG44lpg8K2g oD4RbZKtLXbc/eVmqrNIlQULnyVV+L8LHs58YbADqol8WF2vd01J3+Y2mGsjux6/teZj YhGt8WWfhMJWKZijCrjmENN2wYGdrOo6hz7KpJEPCgK7YQPfcG7ySwhfyOlPiYFqbRUs GUKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id 90si7966076pld.231.2019.05.28.01.29.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 01:29:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 635E389D43; Tue, 28 May 2019 08:28:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id A53FF89C3B for ; Tue, 28 May 2019 08:28:55 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x4S8SraM125394; Tue, 28 May 2019 03:28:53 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x4S8Srke115204 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 28 May 2019 03:28:53 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 28 May 2019 03:28:52 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 28 May 2019 03:28:52 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x4S8Rxuo125039; Tue, 28 May 2019 03:28:50 -0500 From: Tomi Valkeinen To: , Andrzej Hajda , Laurent Pinchart , Lucas Stach , Andrey Gusakov , Philipp Zabel , Andrey Smirnov , Peter Ujfalusi , Jyri Sarha , Benoit Parrot Subject: [PATCHv4 20/24] drm/bridge: tc358767: copy the mode data, instead of storing the pointer Date: Tue, 28 May 2019 11:27:43 +0300 Message-ID: <20190528082747.3631-21-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528082747.3631-1-tomi.valkeinen@ti.com> References: <20190528082747.3631-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1559032133; bh=+lAsyVO4v/OgZEzF3vopHPTns+I7De0g6CNbzAnhPgg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tYPYAZiF56kwhZxDZXRqOgFtIXL6jb127BRDosCuAj9Pu8XR8pvIz4V6xKp1gA4KA LTtt4oKwHaB6ctB+RhoqrChaBQI9FKoX8yNhE3Nj2jSlCHL1jp5fpx1PR0mp/HnyyF cDCvjwVFnbPdIybBGb4Y5Bg1Hf6MuWnEz84MeoZw= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In tc_bridge_mode_set callback, we store the pointer to the given drm_display_mode, and use the mode later. Storing a pointer in such a way looks very suspicious to me, and I have observed odd issues where the timings were apparently (at least mostly) zero. Do a copy of the drm_display_mode instead to ensure we don't refer to freed/modified data. Signed-off-by: Tomi Valkeinen Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/tc358767.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 83cb43af60e5..ffcbecf69d40 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -205,7 +205,7 @@ struct tc_data { /* display edid */ struct edid *edid; /* current mode */ - const struct drm_display_mode *mode; + struct drm_display_mode mode; u32 rev; u8 assr; @@ -1032,12 +1032,12 @@ static int tc_stream_enable(struct tc_data *tc) /* PXL PLL setup */ if (tc_test_pattern) { ret = tc_pxl_pll_en(tc, clk_get_rate(tc->refclk), - 1000 * tc->mode->clock); + 1000 * tc->mode.clock); if (ret) goto err; } - ret = tc_set_video_mode(tc, tc->mode); + ret = tc_set_video_mode(tc, &tc->mode); if (ret) return ret; @@ -1180,7 +1180,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge, { struct tc_data *tc = bridge_to_tc(bridge); - tc->mode = mode; + tc->mode = *mode; } static int tc_connector_get_modes(struct drm_connector *connector)