Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3088276rwb; Mon, 15 Aug 2022 17:50:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR5iwoVFDS9CcqhTXmFgqqEkqAVaEeB4fDnhAjKWbihVRCyyPfr5wdS530bP+2zwAQ3QWJj+ X-Received: by 2002:a17:907:1ca8:b0:730:871e:498c with SMTP id nb40-20020a1709071ca800b00730871e498cmr11772144ejc.651.1660611035375; Mon, 15 Aug 2022 17:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611035; cv=none; d=google.com; s=arc-20160816; b=ggL/wNXNX3/w6bOHk3uZkEWc/hUuRQiMWWJdVkvsfaTlfOiK4jR8BY7/pjK5TPls4U WL8zXM/PJojXIHyWMLn6xUCCe8CQPCI+b17PKQWkC0fphlgIwMmwyKsMuUA3SRVfdkux kISOTIOO+yKuEbDpnSd1Jvhr23l8Ip7R1sqyXA2wjk5wfN/iQKJnUmJRiW5srpB3l60g uQ8Jr0y8CbeDwDrvdJyry2cU7JE1sh4PCS4+htRZIsJUpT5vCE0nHq8Y8FWCmuENAWEA VKZVCqvco+HHeMYJ3eY+W2f+g6/O3XYeWsmsiehWhmXK1Xt+wM2VKnlgEx/HD7n2HH1K Kk5g== 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=JpAWIr4z1Wa70Njg1ntGhjSkwVS1PIGSEe50cTzBeuU=; b=YO0r78WBtfQlRWaBdV9N3P0jZJLB9OK9v6iXznbkuj8wW3BMPRZqScIJoHoZ5wsqwn ZIZm76lStj/mF3l3JjE3iUb8W7pq1FR5yboH5jX41z6zdwOayc35R3Mhrkvudw6S+AXX 1rMZQDjlbv5Jq0J5ns1dgUghrLtfHfDvNAmClEXjP8hdwL288BRrWtPdoTSHuwZrvzoF p1ZNF+ciCiYLjq6eLkV0mbAQ9Z4dbBu9Fr1FYlgCghCxR5/dSb1C1Nlp3sFG8tEhGIvM yM2bXbfo/zdS094j5004D1iBRqSlgsznjTUPC+O1idifNEMtaFjcNjfDV9vjJ/byxI5u j4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h90+Zhgy; 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 f20-20020a056402355400b00440e91f3123si10061303edd.37.2022.08.15.17.50.09; Mon, 15 Aug 2022 17:50:35 -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=h90+Zhgy; 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 S240181AbiHOXm3 (ORCPT + 99 others); Mon, 15 Aug 2022 19:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346133AbiHOXjU (ORCPT ); Mon, 15 Aug 2022 19:39:20 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96E1153D10; Mon, 15 Aug 2022 13:10:07 -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 sin.source.kernel.org (Postfix) with ESMTPS id 98A43CE12E7; Mon, 15 Aug 2022 20:10:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6245FC433C1; Mon, 15 Aug 2022 20:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594203; bh=Wjaxtqdj0Cz1oD7XWH6J2Mu2Qb3gLL5Dk8v/2/lDtnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h90+Zhgyo7OtbL6kJWSK90rvJiCBbPuc4ZBJBuJ2o3WBTVwhSnh81ycw0UcrY+GUC EoJlXTaLMKQtmzscsrnlJVihxPLdOGISHFlPJ7P/k29mkNbPzW9UWj0yW4Ec/L+eTU e6ln1KYVsng2huReOK3vK0GFm2iihoop27U7cJp0= 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.19 0394/1157] drm: bridge: adv7511: Add check for mipi_dsi_driver_register Date: Mon, 15 Aug 2022 19:55:50 +0200 Message-Id: <20220815180455.445369932@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 074c2e650cae..38bf28720f3a 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1393,10 +1393,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