Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1860674rwb; Fri, 19 Aug 2022 10:35:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5lAYDjrUXTBcjKXTXzK+Ggwzk6p+5+MrE4N40yrQg2coUS/gRmvJvs8tzorsKVGEjk4EcB X-Received: by 2002:a17:90b:4aca:b0:1f4:ea26:f589 with SMTP id mh10-20020a17090b4aca00b001f4ea26f589mr14811316pjb.142.1660930529169; Fri, 19 Aug 2022 10:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930529; cv=none; d=google.com; s=arc-20160816; b=Uk1BuOntUWpeVNjNGpyH3ngCWAhiIJwUxBx/rTXT2aqAaJn6LuHhJ0PyFtUWhk5Lbl Q7XqICfll8gPUkyGZyiuKg0eevc2ZOhjbp98ZCjq2cS8oAxVJgpxgQ3xvnhdoHlAzoIe U1w6Zm3dHlYlC+5YWd4IBj5ZWGmaqMkCtPVQgZY/tn0KZ1CtXQWKq5pvt/PG/JD3Kdru Zr+A5pxKXrsvir7CtT8XsxDPce9O7ZGn7vhz5x1CAWXZOpk9p8lcIAhql+r62FSX8rrL ZPX8qqgc0OKDJNW91Gt7Fs+AVPjG2WMmCbD+ToBgXA0MZniUlkPPv3p/XGhUJXKuojBi kHPA== 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=I1sum3AE8DVgo3Fak+CYwqH9Bqu3oRcxwQjFoXl87MI=; b=lZ6zNiiXDst3PDwb7BcEs61HgpU0TQz6E5TFhsj7BRxKz/OeK76niZ/Rv/epXQtylC 9LW7nGU2G1nX34lpnaiYrOznr7C/jcJ2x1e0bEYK+ZXqFvh2S/QIiqyOgUMRUDC7mKgZ ikcoKjQ7S+mw7LP2hTj/KC7uuc03APEDpHuDjEih7a5IRVhnCQ8Xck2LJElqSIZ6TyX3 mvyTiIF2hdoAp4zEoLuoJDo/HUFPbylKm+CHXhnk88WxBxxGJkZZhE81fpU8Kkc6QI8i OonUmMy39Gx9HkQ3rx5mACOM3WUkanWZNeP5eWMx2mDCU2fnFHP1RrWJcImAh50K2zkU sjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BA4bj3Gh; 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 j4-20020a170902da8400b0017139f381c9si4663488plx.569.2022.08.19.10.35.18; Fri, 19 Aug 2022 10:35:29 -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=BA4bj3Gh; 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 S1351759AbiHSQKa (ORCPT + 99 others); Fri, 19 Aug 2022 12:10:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351439AbiHSQHg (ORCPT ); Fri, 19 Aug 2022 12:07:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 962C710E7BE; Fri, 19 Aug 2022 08:56:17 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2A0FEB8280D; Fri, 19 Aug 2022 15:56:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8565DC433C1; Fri, 19 Aug 2022 15:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924575; bh=ATgyo/LWK2OG7s1FSFXr6Qu5zEGCSakxq14VWmNyffM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BA4bj3GhFjN54ig3OyYtoDEE3H4Cj3QaAqrob0n94MNn2LrOEyl65RqOdlsd5LX+d 8KeWqtPnVGTyoVAWzN2+tznF5yjNAE1cIFvvPSUpy6NmzgWLtCY5FoFL8ARsjfkjOe dlr4PBtsmJbHZBTEvwBHtivOVVHVtUB5RBZqsPVk= 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.10 184/545] drm: bridge: adv7511: Add check for mipi_dsi_driver_register Date: Fri, 19 Aug 2022 17:39:14 +0200 Message-Id: <20220819153837.599216276@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 8bac392cab79..430c5e8f0388 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1381,10 +1381,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