Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3694539pxb; Mon, 24 Jan 2022 15:34:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+0mAgSnJQ4ExDRMqgxBp3GDAD5n4CEYR47smTqHcbnvZT9dLIgTqEzaLwddkmMOR/gzw+ X-Received: by 2002:a63:3fcd:: with SMTP id m196mr13228646pga.168.1643067279090; Mon, 24 Jan 2022 15:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067279; cv=none; d=google.com; s=arc-20160816; b=Zb5HFPSvGGs75NSRRjKt3B855BMzUwYORtV0cycIdJV7s4Zov1OoYs9cmY2GTC0Ajd xUXpTMNFlBCYieAq+/N7WWierXed3jJO1/MBWy7URLj7nOs+PntqnIRylU/wuD+dXmTa ZHRBVZHDliK8+ssdFiIYUsXU7uFRbavzEPdRIsMch3zoRxDwl5h0rjtQ1PSm/eXhdAJv NyWLJvUriU+CNE1pTqG6lkS0Z2GEnWx1gmYOpTOny0P7tLrOlp6w0XU9713tSjsimpEt APAf4hJN5+Im0vEPxS0riIYjEDvx9VfMuRShQJOWIVpKRrhwriJj2+hom98mQjp/6cSw uMRw== 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=sMWYKe+q0duSvkiC/hGbR3W/qerCTrku6Um9RPRcCQY=; b=hkFixpF09dcgixcSyJV9xz7xwI7Wz/dT3t0IyyubHDiuaWwh5FUxRs4OEtCpbcsAHx 3QVhM55aBQlfs6r47WQ4zrrVP+q4InJubi6npTWpkhlhGoLyC/0s2nJxZ3RovB5oOCFs +lkfJvAsXPToCFpJEnmNOcAUsh9XhwPtfRKz4eUegg3gmHIPyALOvpHN8Wn05k74QPyy uoB0bkAW3D5MvwFBHEdsZvDgSmjomxl4Nhsa2bWRuW/3TLDj2D/FvMePWKTk6fe9u78J E1pNVM2UWQNVjE9lAEcmvs+ff2kieKorkiwNPBUpEcz8bx+2SlGdEKTyb5jYJ3Xx8y1e 7VPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zxOjx1r0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd6si4954538pgb.465.2022.01.24.15.34.27; Mon, 24 Jan 2022 15:34:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zxOjx1r0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1850780AbiAXXas (ORCPT + 99 others); Mon, 24 Jan 2022 18:30:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1581052AbiAXWLK (ORCPT ); Mon, 24 Jan 2022 17:11:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B6CC0DF2CF; Mon, 24 Jan 2022 12:43:17 -0800 (PST) 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 0523FB8121B; Mon, 24 Jan 2022 20:43:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D15B7C340E7; Mon, 24 Jan 2022 20:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056994; bh=OmsP8HNJCX4jDv8PDSZr05O5ztRc500R/cDcCwePdPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zxOjx1r0pLKWyKWAWtIXV80fS1yjNPjKlli7mDFiPNcrwOsCKuYjePJQWYBQ9Mu6z SiUGIrttMxHVY0noKOkGDkkT9oGuQeTdHlu5iL0YdIVBpjgC9QGSl3mLn7eWwOrwUp GS8nXENpPuZjHq0ld4A++38ZKiWvTWbyw6pjTqs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Arnaud Pouliquen , Mathieu Poirier Subject: [PATCH 5.15 667/846] rpmsg: core: Clean up resources on announce_create failure. Date: Mon, 24 Jan 2022 19:43:04 +0100 Message-Id: <20220124184124.076269450@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaud Pouliquen commit 8066c615cb69b7da8a94f59379847b037b3a5e46 upstream. During the rpmsg_dev_probe, if rpdev->ops->announce_create returns an error, the rpmsg device and default endpoint should be freed before exiting the function. Fixes: 5e619b48677c ("rpmsg: Split rpmsg core and virtio backend") Suggested-by: Bjorn Andersson Signed-off-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson Cc: stable Link: https://lore.kernel.org/r/20211206190758.10004-1-arnaud.pouliquen@foss.st.com Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -519,13 +519,25 @@ static int rpmsg_dev_probe(struct device err = rpdrv->probe(rpdev); if (err) { dev_err(dev, "%s: failed: %d\n", __func__, err); - if (ept) - rpmsg_destroy_ept(ept); - goto out; + goto destroy_ept; } - if (ept && rpdev->ops->announce_create) + if (ept && rpdev->ops->announce_create) { err = rpdev->ops->announce_create(rpdev); + if (err) { + dev_err(dev, "failed to announce creation\n"); + goto remove_rpdev; + } + } + + return 0; + +remove_rpdev: + if (rpdrv->remove) + rpdrv->remove(rpdev); +destroy_ept: + if (ept) + rpmsg_destroy_ept(ept); out: return err; }