Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2817519rwb; Mon, 15 Aug 2022 11:58:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR7HOJr2QADMCrBOEUWTWdDnBKYg8pY1sLs9cFgO2dYjN69TZweP07TPYulv4tidDrJmDTqf X-Received: by 2002:a17:906:cc56:b0:730:a2f0:7466 with SMTP id mm22-20020a170906cc5600b00730a2f07466mr11177079ejb.211.1660589896400; Mon, 15 Aug 2022 11:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589896; cv=none; d=google.com; s=arc-20160816; b=e2FglikoAwE0QINENMifm4LZRDw7+9xOJ8cQgZ5AnbdXCj6avspyOYbzDnVe+SJe1N lrzmEwmoLmQOQr6U9HSCEawTpjbbh2RL4NJmn3IyocBtEgCy5kID/N8hCKZRCXXgJiGi SGe3hWnhCR0EOB7ngyf3kT7wS4W+Hk0bIiqQoTb6WE6ujkcMHEE92kZXxwDlQpsErcxA uPihMxQW8VqGeMjNYmccZt52zHjQo106RcGY9c7vhZh9Bnx3mXbw+S4M1+Z5EAWwk4Nu kIyeVVgoLmRSBuWOvF+jacjnigWe8zq1AztBATCmvn7DC5rIBIlXROsxDIlt7HCmZhLe I4gQ== 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=9yYK+ePWHb7meoAUu9qcIne5ySqA9rkkmBOEqOiRGcs=; b=cShoqAxIPzQ4OaxDV2cpBw2CDQSoXgihO1ssQB8ryYsGrzp3shpNeNdVj+c5z411iN 7JARljwfuRl078Wc2Y6xtHE5VGpS0JNR8z08tServGSPhn5iANPv+BC1r/FTaN4mCy6Z VcnGRIj7uh9EQ9U2Ah+hFq32y5oAHpNZC2KUYYw67GB//8I2fJ/Z++O1vWH6fnrM12jS KCO45hu690Dbj17VcC1bmZ49n7L3itl9zHDBBUtXTXVfeVsgCwR6EVQPAon+73hAL2eV HpWdM6knQ9Etq87ZtVgUlCV+8E/2+V8Ba+s6EYO7l4aZbpTiDhVOy0cGs8JUa1pPeLAU +Qag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QEE0tSGQ; 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 i17-20020a05640242d100b0043bfc7006b0si9255113edc.234.2022.08.15.11.57.28; Mon, 15 Aug 2022 11:58:16 -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=QEE0tSGQ; 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 S244346AbiHOSu7 (ORCPT + 99 others); Mon, 15 Aug 2022 14:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244003AbiHOSqU (ORCPT ); Mon, 15 Aug 2022 14:46:20 -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 E82833FA28; Mon, 15 Aug 2022 11:27:59 -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 6DF9861028; Mon, 15 Aug 2022 18:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342F6C433C1; Mon, 15 Aug 2022 18:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588078; bh=A/7L7qdPZrdDnu57+1oW0UmXRuUAqgLCJZWnb6neBG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QEE0tSGQzmVDfO4gqcEiPEXWFtQzuUkPXKnoPtLvVb7tPv5isAea+3K2m1Qg9ULGI +t17c0bh1LLgwD0bolRk8dR0ktXZxFttEYA+uzkr1SPzQyZfTUH7SR1X2MSzsYBI+H K1/oPNjuoljsCxWb5Yxekk8cJxRHFwJodj11qRuU= 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.15 287/779] drm: bridge: adv7511: Add check for mipi_dsi_driver_register Date: Mon, 15 Aug 2022 19:58:51 +0200 Message-Id: <20220815180349.566051226@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 1aadc6e94fde..7e3f6633f255 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1379,10 +1379,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