Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3388674rwa; Tue, 23 Aug 2022 04:05:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR5reR2ynLUUOeyY20kwavyILyfo3eP0K4tgLOKYFFq56CbinyG9ikQACSq6qp2shxls24rB X-Received: by 2002:a05:6402:35c:b0:43c:8f51:130 with SMTP id r28-20020a056402035c00b0043c8f510130mr3143305edw.393.1661252741393; Tue, 23 Aug 2022 04:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661252741; cv=none; d=google.com; s=arc-20160816; b=zK8u4zUWqikbFyYkS0xn2yrtYDrMMZcZww0R/7cIfqele6FzFSfPz5hC7IqkE6HPNJ fC6UdT8PEQ0f02vK/U4jDA0A+2pXrSVudCG/VE0oV+wSN9TX67EfeuHlP+LillP1bjCH WPNFk9JxPHVwtJEPZRGbNtMMH9T9I1yc+PUTRDAvg8dJKFEyagJ05SkBQOrQsWEz9ELw KWyJ1X1j/K1PZnUq+H/lFyrjDwsM42f+iDCdVIJ8cZgGjjQ6FHCwK3+yCTvBTzUTPOCt F8ZZ+iB7EhdfMo2/wK1abXMN7RmyACFUsk0NLEGXcIUjlErjgFHwx+dlkpIaUy/7bEXR 4OPg== 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=Vz5G0IDXrQOYlTKkygQjul8uRXydD0UaM3n2gp8crus=; b=n6N8AGof/8QXZKgL09+mc0QqLjpRLpwHJLY7hy90funflqEEJAJb+0zbpKRe/9xM1/ 63WnjE74TP6qPtbpfW7IMQDSVs6QG6DsZ08rPQzrwxwPQGMJo9T1xhf4Zpp1R35w6hxy 0uy7Hr0XuMgREdlQWeoUVpANxzdd2TIgAZ0CDrR+VPdWhSLwxYF5x3mB1lPxfXsCMi+Z NTWjDdVqkCidnJsVD4RE9E0deQgo+oEFk7ecQI1l7J1rw/PQH8ji0QBHelrMS6si+zup GbTH8LJxezZW2c0lxeNjrsh8LyhOlaK28Wlt7Av56yp/l8VMsJ4xboC5HL+p5dph255X koPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F2mjt2gx; 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 hc39-20020a17090716a700b0073cfa9b42a2si10405032ejc.445.2022.08.23.04.05.08; Tue, 23 Aug 2022 04:05:41 -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=F2mjt2gx; 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 S1345190AbiHWJsY (ORCPT + 99 others); Tue, 23 Aug 2022 05:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352177AbiHWJqB (ORCPT ); Tue, 23 Aug 2022 05:46:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136992CE16; Tue, 23 Aug 2022 01:43:33 -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 DADB661485; Tue, 23 Aug 2022 08:43:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDB6BC433D6; Tue, 23 Aug 2022 08:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244190; bh=FnF15LZwNDPxhljz7cmUOV0fzoKOxDGUuWynoWR/aTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2mjt2gxKGOYDEGBKCnyboElcNdJIpHxdsICEZNd3KRvp2Wmo5ZMssnW4/i55M/+8 DzyKxhDf3JveabyneIFRKqzn15fa1LFf1wy/iOSFDqObDnuv6xa85TBuCAa+NIwf4W 6F2yETregWS+uZkkTSPr51T3DPaPY8dXpwLB0dwM= 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 4.14 065/229] drm: bridge: adv7511: Add check for mipi_dsi_driver_register Date: Tue, 23 Aug 2022 10:23:46 +0200 Message-Id: <20220823080056.049597945@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 3c94d838863e..f5195d9841f8 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1213,10 +1213,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