From patchwork Fri Sep 24 00:33:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 12513809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F822C433EF for ; Fri, 24 Sep 2021 00:34:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEEF061278 for ; Fri, 24 Sep 2021 00:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DEEF061278 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC0C16E134; Fri, 24 Sep 2021 00:34:10 +0000 (UTC) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47F596E134 for ; Fri, 24 Sep 2021 00:34:09 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id g2so3133008pfc.6 for ; Thu, 23 Sep 2021 17:34:09 -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=yEiQvpP90gfZjBo9eARQA/dGO0k9EVx8RLJE4fBEffo=; b=iR0mGqFCRUve5BCBSrrRcCdy8Dh8jyvq9GbxxKiMzpchO1ZIxZb+bU3DDa8VjY75qD aP79hLfIzswYkIp/Lq5ReRkVdZiGpLFR0q6LI+w1MVPOGcx8B2kVGMmAtwlsIaGLFHtm 1gM/Mh8A0kxKQFbL1vfPtfs69DXNEF02mUmOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yEiQvpP90gfZjBo9eARQA/dGO0k9EVx8RLJE4fBEffo=; b=OrDXxNZnkVA2ZiSyicwG5stCMCL5hvKeoSpKwyLdhIikPJ6niqpXXT/aWHI8J1W1qO F6ui6E5/d6yRjUkyZR0LB4ub0Xiaa+QuoDBJA/KM0DAcLPnyTtquUSdAXxWuEuliSxFb 9mOWNDRYtSNMFg01GKbdunSSbsX+k9AY0KpnDXxwvdEZY9OCZ2Q6MR6TVpUwsQfOc2mg F4zVHierRXDjHa7Oz2kiVlPvzyMkYKniRGGfYFj56Kl0Gwmf02Y9/HQyMBHFZJeqWVgZ UTBpxKVLkTWCFydQ6KdGT9lWEdSKBDG7axIVUzDRMAFaRG8HuOMlESTgoCN7U47SOJ4z myGg== X-Gm-Message-State: AOAM5324LZNjY0n0DLy1Q+/6lyy55X9GwDojtVvKsrATT9F7vRgDDQLT TcB9L/Qdm4SZnDC+F8sV0F2E9g== X-Google-Smtp-Source: ABdhPJwi1hDYHJLiTqVsQKo2Qj1wDbfpdCAQz2Fk7pGYUTkrXOEnn2izG27x7hKRaxz+DtaCR3lmDw== X-Received: by 2002:a05:6a00:1944:b0:438:d002:6e35 with SMTP id s4-20020a056a00194400b00438d0026e35mr7047397pfk.20.1632443648891; Thu, 23 Sep 2021 17:34:08 -0700 (PDT) Received: from localhost ([2620:15c:202:201:74de:c8b7:3a35:1063]) by smtp.gmail.com with UTF8SMTPSA id z17sm6932766pfj.185.2021.09.23.17.34.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 17:34:08 -0700 (PDT) From: Brian Norris To: Sam Ravnborg , Thierry Reding Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Heiko Stuebner , Sumit Semwal , Jagan Teki , Brian Norris Subject: [PATCH 2/3] drm/panel: innolux-p079zca: Delete panel on attach() failure Date: Thu, 23 Sep 2021 17:33:54 -0700 Message-Id: <20210923173336.2.I9023cf8811a3abf4964ed84eb681721d8bb489d6@changeid> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210924003355.2071543-1-briannorris@chromium.org> References: <20210924003355.2071543-1-briannorris@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" If we fail to attach (e.g., because 1 of 2 dual-DSI controllers aren't ready), we leave a dangling drm_panel reference to freed memory. Clean that up on failure. This problem exists since the driver's introduction, but is especially relevant after refactored for dual-DSI variants. Fixes: 14c8f2e9f8ea ("drm/panel: add Innolux P079ZCA panel driver") Fixes: 7ad4e4636c54 ("drm/panel: p079zca: Refactor panel driver to support multiple panels") Signed-off-by: Brian Norris --- drivers/gpu/drm/panel/panel-innolux-p079zca.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c index aea316225391..f194b62e290c 100644 --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c @@ -484,6 +484,7 @@ static void innolux_panel_del(struct innolux_panel *innolux) static int innolux_panel_probe(struct mipi_dsi_device *dsi) { const struct panel_desc *desc; + struct innolux_panel *innolux; int err; desc = of_device_get_match_data(&dsi->dev); @@ -495,7 +496,14 @@ static int innolux_panel_probe(struct mipi_dsi_device *dsi) if (err < 0) return err; - return mipi_dsi_attach(dsi); + err = mipi_dsi_attach(dsi); + if (err < 0) { + innolux = mipi_dsi_get_drvdata(dsi); + innolux_panel_del(innolux); + return err; + } + + return 0; } static int innolux_panel_remove(struct mipi_dsi_device *dsi)