From patchwork Fri Nov 25 17:45:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 26111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4194780wrr; Fri, 25 Nov 2022 09:55:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4PheYnFlaYUHLTcx5jIensUQCD523CBQwZBCLPxzs+Fe1Vu1nAuNT6VQsCuboSJRySKYGs X-Received: by 2002:a17:902:f813:b0:187:12cc:d6f1 with SMTP id ix19-20020a170902f81300b0018712ccd6f1mr27007897plb.63.1669398920071; Fri, 25 Nov 2022 09:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669398920; cv=none; d=google.com; s=arc-20160816; b=E4BaEQ4pAdMdz8eqVtMWUA8j41hMa/G5J4ar5arQg9ADXawRSPCb3m4T/zry/+dhoQ WvZln7pWm146zHSwM/DwT2X9XU9Hejr/y0VSgI2wwxIbhphW8CVho8/nmviHv0+DdHx3 MmA+7lGLXL7OqrWQ89AfbW3NP3JsXU7RYLnyxf99tHV4cW82yOMktABbkRV5sxlQjvv+ wfgX6WcUiq/qPI9xDDN3eJILGVrJEMbkmCxPLK/+WgYjkZRNiAMIMl45g9CloQLRO/QO iNzWWZHYmCOTa/Qjb0m4HBhrkmvfJKDXXNajGXyIv8NPJSzuFigK6r5heEAVbMr/LaL0 ylNw== 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 :message-id:date:subject:cc:to:from; bh=znl78HPyJyiS1PbUjI3B9osk31KEfoObmVFqflf4zuI=; b=pRQjvuZGF8l/xCCHl/vT1NQNJt+Ay+hgiR3MjKmRX7DOfMSnUlzPXJp60Z+JMOmegN 84MQ0zahWFQiaCOYpAg1KC47+OaxtuocVtQ80xpPNc5NW8c0Z5UxGSmLlUDxcWH7LC/K HPUif4jI6fArksHAfOX66Rw0ADYoWtXK2UZkD76LJA9rIApDQD0Hy3IRKOygGUP9g46/ dTUgMxNCmglYYJlbMLnWzwrd8wC6k4z4gDxqUQGVjvKa+UMKAPnqe6R/6Dks4smvwAZI lsDT+p2/D/B8XwUt18dQ1lovgR9gSMPNRbh+1FxQnoVXgcmpXoqrKArxavGi6Tnh3Ovc tI/A== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iw22-20020a170903045600b001869de3edcasi4174196plb.466.2022.11.25.09.55.06; Fri, 25 Nov 2022 09:55:20 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiKYRpN (ORCPT + 99 others); Fri, 25 Nov 2022 12:45:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiKYRpL (ORCPT ); Fri, 25 Nov 2022 12:45:11 -0500 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3140E537D3 for ; Fri, 25 Nov 2022 09:45:09 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id ycl6oRgotNKuIycl6oW0Qo; Fri, 25 Nov 2022 18:45:07 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 18:45:07 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Srinivas Kandagatla , Amol Maheshwari , Arnd Bergmann , Greg Kroah-Hartman , Vamsi Singamsetty , Bjorn Andersson , Abhinav Asati , Mayank Chopra Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-msm@vger.kernel.org Subject: [PATCH] misc: fastrpc: Fix an error handling path in fastrpc_rpmsg_probe() Date: Fri, 25 Nov 2022 18:45:02 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750491641648577461?= X-GMAIL-MSGID: =?utf-8?q?1750491641648577461?= If of_platform_populate() fails, some resources need to be freed as already done in the other error handling paths. Fixes: 278d56f970ae ("misc: fastrpc: Reference count channel context") Fixes: 3abe3ab3cdab ("misc: fastrpc: add secure domain support") Signed-off-by: Christophe JAILLET --- First Fixes is when branching to the error handling path should have been introduced. Second Fixes is when misc_register() have been added. --- drivers/misc/fastrpc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 0f467a71b069..22163728bd85 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -2127,7 +2127,18 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) data->domain_id = domain_id; data->rpdev = rpdev; - return of_platform_populate(rdev->of_node, NULL, NULL, rdev); + err = of_platform_populate(rdev->of_node, NULL, NULL, rdev); + if (err) + goto populate_error; + + return 0; + +populate_error: + if (data->fdevice) + misc_deregister(&data->fdevice->miscdev); + if (data->secure_fdevice) + misc_deregister(&data->secure_fdevice->miscdev); + fdev_error: kfree(data); return err;