Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3180190pxb; Mon, 18 Apr 2022 18:16:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwveYCcRwu4sAth3qlOTXCMnNAa+46GHXQ6ODpBR9tF2EN9SXlRVi1SLRBWvZyUgwiXYA/Z X-Received: by 2002:a63:7c06:0:b0:398:31d5:f759 with SMTP id x6-20020a637c06000000b0039831d5f759mr12440748pgc.513.1650330969104; Mon, 18 Apr 2022 18:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650330969; cv=none; d=google.com; s=arc-20160816; b=L10RNS6lsJfF+UI93jrxigtCYfuT0gKI2YNcRnBRlWMmoNmLaUx+enLNVQywb6vphw zDfmb6VmhpZlzfjqL4KLi2sTrmIyNdR3fOAWrG3hdAQ3w1k4096uHTF8THtFRjjqbJ1M MYggdT7yS0myXq45FXE/tL4KtY+DOtgFHxiVfFWq9r/nVj20r9exB8kUqfwkc83IPyY4 K6M3aELf4wVcGo8DSr0T88raJRBcbEGMqtF+dEScy7s+qQsF8PxNDj3M8IkF9qJ6/EHD naJzvAhDoc/neAR45cllLWFJOzSV2YdA3w3IGijMeanB3VQ17JGl21AG4dTAMajthXV9 uykA== 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=PpGy5ipcmxRVtVIXw8PbWCN6B9+3X0iWYDB86QD1AzM=; b=x9vE7bpq3sA1HvSCAVhEi8nG3Ky59cbfI47kJayjtVZz8Pd5juLKzmv4PhQy1Qu+n3 K02oXHD4sNavrFfYfuKKfYI1nGWxSSEjXxxbYeIjjkCjk9pyDfNdxy91MOk6ZfrAZZLF Q+NYt9S/dWfMD+1DeEXSiz6hE1lXy5UQBKka3ZX18USGHd49Fd3qRxDl9paHf5fMNoX8 fpuO2gwXwCz4lfcFbOlRmLIWWMdfA2eBAwUhEdDFWQf6wXuBqVWf9j6psvwGnK/BVy25 tZMjX8fKLxCVugz6hDTVu/2rPqhbgyPGa+cSsx7To7d+wANgRMesf+NYwrfze9tCpUfi WROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S4RxF87H; 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 h185-20020a6383c2000000b003a30633d0basi8948974pge.194.2022.04.18.18.15.53; Mon, 18 Apr 2022 18:16:09 -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=S4RxF87H; 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 S239472AbiDRMhh (ORCPT + 99 others); Mon, 18 Apr 2022 08:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239038AbiDRMcW (ORCPT ); Mon, 18 Apr 2022 08:32:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4755512600; Mon, 18 Apr 2022 05:24:15 -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 6A888B80EDD; Mon, 18 Apr 2022 12:24:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0E9DC385A9; Mon, 18 Apr 2022 12:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284652; bh=6ooF/igZC8v7MEPYVcrIFfABu53YfusY7o79++JXHv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4RxF87Hvb177crG5fzbR9DchAMmrDSo52yo5zG7FtS0MoTTYz94KQPHe4I3D/enj O+NzGk+4/lu7w9qa1buMHII7upGYdr/5y2+XXyYE168PEO2cX7fbUQeM4o7y3Wofb7 C3aaRfRvczwHuOcydtGgoFFix7tI+XPa6dx1kL+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergei Shtylyov , Johan Hovold , Krzysztof Kozlowski Subject: [PATCH 5.17 185/219] memory: renesas-rpc-if: fix platform-device leak in error path Date: Mon, 18 Apr 2022 14:12:34 +0200 Message-Id: <20220418121212.056675339@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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: Johan Hovold commit b452dbf24d7d9a990d70118462925f6ee287d135 upstream. Make sure to free the flash platform device in the event that registration fails during probe. Fixes: ca7d8b980b67 ("memory: add Renesas RPC-IF driver") Cc: stable@vger.kernel.org # 5.8 Cc: Sergei Shtylyov Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220303180632.3194-1-johan@kernel.org Signed-off-by: Krzysztof Kozlowski Signed-off-by: Greg Kroah-Hartman --- drivers/memory/renesas-rpc-if.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -651,6 +651,7 @@ static int rpcif_probe(struct platform_d struct platform_device *vdev; struct device_node *flash; const char *name; + int ret; flash = of_get_next_child(pdev->dev.of_node, NULL); if (!flash) { @@ -674,7 +675,14 @@ static int rpcif_probe(struct platform_d return -ENOMEM; vdev->dev.parent = &pdev->dev; platform_set_drvdata(pdev, vdev); - return platform_device_add(vdev); + + ret = platform_device_add(vdev); + if (ret) { + platform_device_put(vdev); + return ret; + } + + return 0; } static int rpcif_remove(struct platform_device *pdev)