Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3FA14C4332F for ; Fri, 14 Oct 2022 23:11:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D4CEA10E154; Fri, 14 Oct 2022 23:11:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DEE710E154 for ; Fri, 14 Oct 2022 23:11:12 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.bb.vodafone.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id BAB6584D7A; Sat, 15 Oct 2022 01:11:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1665789071; bh=/gEZWtVQReoks5p6jr4VqJcWXgIIfkBvwefc8q3ciFc=; h=From:To:Cc:Subject:Date:From; b=rTsAJxXKfsCnw+Zo+OGA/pEn/5Wz+IQRrKzod5BhOrjNkN8vSWYRpTRokQlGVUcMG 6bL5XK1BEGCibqkbqS59/O0LDVlhAEgYQK6vZh5vm5RJ32e5zRBZySeVOWAFPFzowu QXja6+iiqYxklS085zhHHskfCBdrA6cyUiS4oQ4PvF1Vf8wNIaWV1JAiqFRbecmyy0 87UgCwPjeUZm8MSKdeI8WakSnbuiCFV9dAsY0f550i+cCIplv6wqc8LvkL1f5hffHV KzifIhV5Hw+P8oIZtUOg/W34Rxh7GUBMnTy+5EgcXe8w/6B95EL9tVWY5nQ0K4WZHb 1htCnDEGD8LGA== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/panel/panel-sitronix-st7701: Remove panel on DSI attach failure Date: Sat, 15 Oct 2022 01:11:06 +0200 Message-Id: <20221014231106.468063-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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: , Cc: Marek Vasut , =?UTF-8?q?Guido=20G=C3=BCnther?= , Thierry Reding , Jagan Teki , Sam Ravnborg , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In case mipi_dsi_attach() fails, call drm_panel_remove() to avoid memory leak. Fixes: 849b2e3ff9698 ("drm/panel: Add Sitronix ST7701 panel driver") Signed-off-by: Marek Vasut --- Cc: Guido Günther Cc: Jagan Teki Cc: Laurent Pinchart Cc: Linus Walleij Cc: Sam Ravnborg Cc: Thierry Reding --- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7701.c b/drivers/gpu/drm/panel/panel-sitronix-st7701.c index baeb952b6e244..0b8cf65172ff7 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7701.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7701.c @@ -754,7 +754,15 @@ static int st7701_dsi_probe(struct mipi_dsi_device *dsi) st7701->dsi = dsi; st7701->desc = desc; - return mipi_dsi_attach(dsi); + ret = mipi_dsi_attach(dsi); + if (ret) + goto err_attach; + + return 0; + +err_attach: + drm_panel_remove(&st7701->panel); + return ret; } static void st7701_dsi_remove(struct mipi_dsi_device *dsi) -- 2.35.1