From patchwork Mon Jul 30 15:26:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10549225 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1FEEA755 for ; Mon, 30 Jul 2018 15:27:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B141A293F3 for ; Mon, 30 Jul 2018 15:27:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A59DF297DE; Mon, 30 Jul 2018 15:27:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91442293F3 for ; Mon, 30 Jul 2018 15:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726663AbeG3RDJ (ORCPT ); Mon, 30 Jul 2018 13:03:09 -0400 Received: from mail-yw0-f177.google.com ([209.85.161.177]:41435 "EHLO mail-yw0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbeG3RDJ (ORCPT ); Mon, 30 Jul 2018 13:03:09 -0400 Received: by mail-yw0-f177.google.com with SMTP id q129-v6so4500483ywg.8 for ; Mon, 30 Jul 2018 08:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=29BnNg+33arf3YVU9GWJNNZ9WX6B4oKmFqaQn7yH/nk=; b=hlu+EwO2NoPgEKoqvfnG2KhaDNcIq/cKRwSES/unY76EsCPP9doWTglrlBwj2VL6lk BsXgH5S75jWLweJIUV+IEKaDaj9Va5QQv4f+pJ3WalaDIBwG8pBIwRqv5u/fC8JuI7nu ej2+dZw/dBG5y8LA9ORSwU60A8arwhYKOY1zw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=29BnNg+33arf3YVU9GWJNNZ9WX6B4oKmFqaQn7yH/nk=; b=fD4O9+viOB58ihpV1/6TNduNW3t2XRx6SSQc1ibUT9ItZ/AMpsLWIdBETVAh1uhVwN 3n1+aCkSSheonLoU0VakmX8zH0zPb8Wpi7icSaTRBnWrdt3pJ+8fWHIUB2TR7PDmNxpQ cpLB99pWhqGVPflvX/rn1M6jZvXhfR+ofi8fdsWcDRTK9OWBL5a3rqK212R/f0C/TmGX yvZR21Yo+cpr/+wZOrhjOC2Sa6cDXrCtlWdTAVOHUM1jlnXUdIDIGk+GSxha0QeOhKpW 1GGTfpB1CReG4hdY2cY1KR18MbJg0Q7mt+RRAA+emalttypzIMrtmxnHrETaoLOHLZuw AExg== X-Gm-Message-State: AOUpUlGgiQ4/sBpdaOgscaYB18AfhG/m6CLJcp3fZmZMJ+uH5g+MnWxL qBDsYKVvp/70b55IfXtLocFlBw== X-Google-Smtp-Source: AAOMgpef8jWoZ+GaeuGHlTsTSzyxefKUmTrtZ3OEWKKjgWIlNdhEJv6dFmqVExnm0NycnibZXKpoVw== X-Received: by 2002:a0d:f704:: with SMTP id h4-v6mr9029623ywf.240.1532964459666; Mon, 30 Jul 2018 08:27:39 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id s63-v6sm937383ywd.63.2018.07.30.08.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 08:27:39 -0700 (PDT) From: Sean Paul To: robdclark@gmail.com, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: dianders@chromium.org, Sean Paul , Archit Taneja , Abhinav Kumar Subject: [PATCH 1/3] drm/msm: dsi: Initialize msm_dsi->id to -1 Date: Mon, 30 Jul 2018 11:26:53 -0400 Message-Id: <20180730152658.157098-2-seanpaul@chromium.org> X-Mailer: git-send-email 2.18.0.345.g5c9ce644c3-goog In-Reply-To: <20180730152658.157098-1-seanpaul@chromium.org> References: <20180730152658.157098-1-seanpaul@chromium.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently msm_dsi->id is initialized to 0 during kzalloc. If bind fails for a secondary dsi device before its id can be properly set (such as during dt parsing), the id will point to the primary dsi device, causing its reference to be removed from dsi_manager's global (msm_dsim_glb) array. This patch initializes the id to -1 and checks for negative in the manager cleanup. Cc: Doug Anderson Signed-off-by: Sean Paul Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/dsi/dsi.c | 1 + drivers/gpu/drm/msm/dsi/dsi_manager.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index ff8164cc6738..ee07d58c2d97 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -83,6 +83,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev) return ERR_PTR(-ENOMEM); DBG("dsi probed=%p", msm_dsi); + msm_dsi->id = -1; msm_dsi->pdev = pdev; platform_set_drvdata(pdev, msm_dsi); diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c index 5224010d90e4..80aa6344185e 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c @@ -839,6 +839,8 @@ void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi) if (msm_dsi->host) msm_dsi_host_unregister(msm_dsi->host); - msm_dsim->dsi[msm_dsi->id] = NULL; + + if (msm_dsi->id >= 0) + msm_dsim->dsi[msm_dsi->id] = NULL; }