From patchwork Tue Mar 19 10:41:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 160556 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3712119jad; Tue, 19 Mar 2019 03:42:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5k7QBJDOu4srhmljYUxO+Qll1IdbvNzEyq0YVVQRbAmM7GNDv0FmLD1AXhJgfrdm/Wgq5 X-Received: by 2002:a17:902:bd96:: with SMTP id q22mr1347094pls.7.1552992177701; Tue, 19 Mar 2019 03:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552992177; cv=none; d=google.com; s=arc-20160816; b=DyDcyQNPqV0kHe/pLSYLARW1y3xIyYg7oL99q72HMvQH1TgLenS0bxkKfFZ5jXRgFZ taAdHxtBBOyGWG0Zi7Ahzn6fBMZfAIQHlotG0aC5njWdvrCHFb2gmDZb2/PQLtYnpgm8 wYgSh+641nDQMG7/KbxSlz4Ol5m/gDnh98/21kv5P3eWqFDdl/po+K9VeupHh4j2pjX+ P6czuZ++nm/D/7XAkt494taihMkCxmRBYusQIA0Ljb5ElyUuhJo6J2PyEiX8UuIFKfmi i1Jn3Q+3iVM4fb2giYqt28lc5cSvmEGJuFc24zbij09zStw3PQqJ/QdLgQxGvA0rkhwW l0tw== 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=AD75nBhV3txtbuxsRhjTpOUFOEFTJrHZN+VADjTYda0=; b=BxN3pFtcG81opd88cgnCHxDMkLLIHbPsVUyDkOzKUghLSlo/52RQH8WD5JJ+cw76K1 U/f1isaoOILyNiVRbTr4PAEdqAUNc05potJDrwSWtrPOYDNdi9KTnQmnqyvKPahnjEir Wodza0bFz5heUNBKFZs37LHEInITrYAJW6IQw5SHKeD+DHbnpmPlkwYirwE+3q+FYOHg Sr5zeH74IhIkldT+H+TxFHWzkt/Pzqg9NseCYa3C0jCLN+K0qWYhvm7ylUCsCMDe5twu m04CIi6oIrQKFG9nuX74DYGdkO7cnIGXRiQmbE2wQpUHwDvzr0UM/i1E+d9cA9+f4v1e 5DHQ== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id g8si11793300pgd.52.2019.03.19.03.42.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 03:42:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 000EB89AC2; Tue, 19 Mar 2019 10:42:53 +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 53B8C89AC2 for ; Tue, 19 Mar 2019 10:42:50 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x2JAglfO076875; Tue, 19 Mar 2019 05:42:47 -0500 Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x2JAglH3105935 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Mar 2019 05:42:47 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 19 Mar 2019 05:42:46 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5 via Frontend Transport; Tue, 19 Mar 2019 05:42:46 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x2JAfxlc019091; Tue, 19 Mar 2019 05:42:44 -0500 From: Tomi Valkeinen To: Andrzej Hajda , Laurent Pinchart , , Lucas Stach , Andrey Gusakov , Philipp Zabel , Jyri Sarha , Peter Ujfalusi , Benoit Parrot Subject: [PATCH 19/21] drm/bridge: tc358767: copy the mode data, instead of storing the pointer Date: Tue, 19 Mar 2019 12:41:12 +0200 Message-ID: <20190319104114.12077-20-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190319104114.12077-1-tomi.valkeinen@ti.com> References: <20190319104114.12077-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=1552992167; bh=Mg8a+Ef+AE8FV7gpcCtx0I5JJgvwtNOCus0ientVzuw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aObv5YY7chuoKPM+BzfqtyyQQFW5HS0u6MeJWqJMlEhHP9HX7CUWO5EXl18LQShNa gHBrcDTCrkUn7VjNaxsWoOEndrK+hoIIkIEoQWgMrU/T/n/7SDEFx8a9hL1ORaUKcl LsGVmal0aivZAwRR7mkZYACGeinGLI/fPtoq65Uk= 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 --- 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 114d535c296b..8732d5b05453 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; @@ -1021,12 +1021,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) goto err; @@ -1166,7 +1166,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)