From patchwork Fri May 3 12:29:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 163319 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp547108ill; Fri, 3 May 2019 05:31:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD8BKK+AXZuJBd14s/JypBpvK1MzK6zA1UqFXGkamPGK85w99eNWb9DuboCSlsQIhNl4p+ X-Received: by 2002:a17:902:8642:: with SMTP id y2mr10059366plt.104.1556886695313; Fri, 03 May 2019 05:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556886695; cv=none; d=google.com; s=arc-20160816; b=CBcyG+sf4nIRYjHSxFb4XOgTh6Fb8B1bqlpORY1nPc+dXkrwhy/a8U4Hl9cZ8ypCi3 /hLi7ww66ZjCSqPZpjbkJvJ1SxtOFtd31zY2suq2cjW/ClioqIwQ/5t4MLAP7GFZhyr+ 16/M7zL3sMx/lZEnF1Jgtr+8uKCCQpRr4/MZMSpBCChqWhXksKGM0BEz5whbX3FtSpdx kcR53LWs69ORCxMOwju9RiyIg2OkZcfh+qhtSaOLd6R6ypnWgrA25Y4rAP36VH8vEAfQ Fo7TvTO1i3NFvNen+Jli9vs0p4enPG+7sUnZIKYsu0srtlRmzO7Pfy8EJgDWNef8ljiz gG/g== 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=6F6wFIL0UBKdS9M3pgFWuK/olu3tA9wsEnTcIMMm5yM=; b=TK9Brb8FSAV8lpdNygktPw92j5Q7yLAlA0IglKImCSBdpEd44g6/zoBZezRCVPU7Eo BMFFc5NhK3lSuTlHkQ0CI6nU2vDc1fq15qk7BQ3i/PYtl24sCRJRozll1Bj6IdfU/sR4 YtDkNZH5Rrop51JfilohKbYlIgaQrN4K3AZeuhvEwtzGYECunfCjB71e2fOshxzCCEGb Xe5nj/h0g6HiWp18nErAtXQqF6uuEBz23UAqtWXvB1EOVNE1+maUnBqS5Ibfw/5zU4Lc JvhimccelHByuw1jgn+bFuj0KeIlpqUsCguBO3oeaJb2E/9SAGCycy5b0mKFXmQoXh9u 0ubQ== 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 c17si2035692pfn.30.2019.05.03.05.31.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 May 2019 05:31:35 -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 058E68919C; Fri, 3 May 2019 12:31:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB3C389F45 for ; Fri, 3 May 2019 12:31:31 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x43CVTAH098068; Fri, 3 May 2019 07:31:29 -0500 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x43CVTC4129210 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 May 2019 07:31:29 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 3 May 2019 07:31:28 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE111.ent.ti.com (157.170.170.22) 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; Fri, 3 May 2019 07:31:28 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x43CUYu4002029; Fri, 3 May 2019 07:31:26 -0500 From: Tomi Valkeinen To: Andrzej Hajda , Laurent Pinchart , Lucas Stach , Andrey Gusakov , Philipp Zabel , Andrey Smirnov , Peter Ujfalusi , Jyri Sarha , Benoit Parrot , Subject: [PATCHv3 20/23] drm/bridge: tc358767: copy the mode data, instead of storing the pointer Date: Fri, 3 May 2019 15:29:46 +0300 Message-ID: <20190503122949.12266-21-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190503122949.12266-1-tomi.valkeinen@ti.com> References: <20190503122949.12266-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=1556886689; bh=RxXowr+DKJ0osrSn6l6k6daMO+MYKrMbgEShpG+uCDY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Vz+XJxANC8RkrWGu2eKbpML2Hx38LSRnyNCWBFoWo045+FncXjcnrSFodHbO2BTtO fwCabebVYtC/pWQtUjdMhGbMJ05DY4mm6OxaCL1Z6hDq3PiWhcDkoS1fw3Jl/T6rDt qmIezKb26BFl7maThF8hAqSa1Ehwgv9fo3UNp9Wc= 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 591bf64ac916..8f6d601def3f 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)