Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2928953rwb; Mon, 15 Aug 2022 14:14:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR514Kn1XkPLe89J9L9/hM1rWinYvOXELegxXUpglYg1hB963NbSZ0xCZuRWr9j5yVDLbQFW X-Received: by 2002:a17:903:234f:b0:16f:18a6:451a with SMTP id c15-20020a170903234f00b0016f18a6451amr18379755plh.82.1660598077321; Mon, 15 Aug 2022 14:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598077; cv=none; d=google.com; s=arc-20160816; b=wuPrWM/FtR03pbdPSkydPVw9hkKswpfkO2sJo543lcsNO4uvbiZqH2u6T4a/s+PpD6 5w7Jt0EuenKxKY4q5McpPzcezk9Tdp/vH3b/zr+HVemHFABAIFTgGLQyqc3w8LEQNvXE xaQ5dWrJD6R79fAfEm/BJcd7iUKicUTGgHrHxA+WYYSytTr0qwn9iCYQg2vIK5RbrWou RbuSyXn5Us6V5Wvjfxlz2eLn0fRtZxlGMzHKPWT3GDgW5N7N5vIqlrG5x/XJ2AS+0Akr OLU8nS/l8Cl4dQNWFwt5HqI9m7n16lQM4/rn6QcIPj6glCyCvb3GJqwmOt9kXQKKJSTv yNeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TCSyID/pq8wdmj6le2mW6VcMqBg8Dxh2V+S0udl8TlE=; b=YrRq5p5EKHC/reoW+G97zMaeDJ0q0Us0rifelxCyU05Ae81g3NDfZh/dhjZljCmj3u wm6H9CuM2xALELjOKyDgklXf2HYA7rzZaZcjnBgL6W4IZTeFHbryBO5Q4rksxDMT/U0Z prVmVpsE1Puh3tcx8NoV/IfAVnfPZu6/g2nIqoLdQt//v0MuHFIxShOk1UvAPW14v4Hg iJrHzVbZIp4B5fKkTgoMSCw9la8aw9MVzKPYG/MJCqKx0e0Mb1JEEWlCz5/HJosHqQH6 bFI7xc4uGOFfqshXkujfmeLlaK/cF8/IgnaOMZFBjN0wwqXDUAQDyX0rsEaMx3GMHzGd 3lMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0xG5M90H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a630b46000000b0041ca4aef3d4si11163003pgl.44.2022.08.15.14.14.22; Mon, 15 Aug 2022 14:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0xG5M90H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbiHOVCx (ORCPT + 99 others); Mon, 15 Aug 2022 17:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344940AbiHOVAs (ORCPT ); Mon, 15 Aug 2022 17:00:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97E5D5071C; Mon, 15 Aug 2022 12:13:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5413A6009B; Mon, 15 Aug 2022 19:13:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21716C433C1; Mon, 15 Aug 2022 19:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590786; bh=yUTNofOgq1olQPMANgZ2ZGeArnRYj09pXtkAyVjYFhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0xG5M90HE9CAjcvSLS7o7OLfz1q3ggl3NbxQpD6PmsZ6L7X3/uAiBiGJh/hb3vYaO qfnYvDJceyZOYpYZ9KtGphaEoO4FQeBOT2rgmRlgvSKr4fgqxICUQshaSmhUM/3f1O 7Pkb5VAeRDFih2ZUJo+FBoNrmmcaPqG2GMBH4WIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Laurent Pinchart , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.18 0371/1095] drm: bridge: adv7511: Add check for mipi_dsi_driver_register Date: Mon, 15 Aug 2022 19:56:10 +0200 Message-Id: <20220815180445.066576965@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiasheng Jiang [ Upstream commit 831463667b5f4f1e5bce9c3b94e9e794d2bc8923 ] As mipi_dsi_driver_register could return error if fails, it should be better to check the return value and return error if fails. Moreover, if i2c_add_driver fails, mipi_dsi_driver_register should be reverted. Fixes: 1e4d58cd7f88 ("drm/bridge: adv7533: Create a MIPI DSI device") Signed-off-by: Jiasheng Jiang Reviewed-by: Laurent Pinchart Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20220602103401.2980938-1-jiasheng@iscas.ac.cn Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index fba6ad3bb6ad..f4d6359f6219 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1384,10 +1384,21 @@ static struct i2c_driver adv7511_driver = { static int __init adv7511_init(void) { - if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) - mipi_dsi_driver_register(&adv7533_dsi_driver); + int ret; + + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) { + ret = mipi_dsi_driver_register(&adv7533_dsi_driver); + if (ret) + return ret; + } - return i2c_add_driver(&adv7511_driver); + ret = i2c_add_driver(&adv7511_driver); + if (ret) { + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) + mipi_dsi_driver_unregister(&adv7533_dsi_driver); + } + + return ret; } module_init(adv7511_init); -- 2.35.1