Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3580366pxb; Mon, 24 Jan 2022 12:43:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJymc81L5GqKy9X3QQRWwe/z5bYK24EXUiZDQpjndyiFikRdR4LqyJ02bQ9GpjEb4GtGtGEW X-Received: by 2002:a17:90b:b06:: with SMTP id bf6mr43458pjb.61.1643057005724; Mon, 24 Jan 2022 12:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057005; cv=none; d=google.com; s=arc-20160816; b=rsq7BVbudlPb70v9w0P1tgMIZyQGn2cUMf0gUM2urWqoXEWet75QFGT/8iqqr7IYTM mSNkwj3EDL+AaKqyO8DsF5sw9IgeNQOt8COw7UA9fyV4gIK2axGUkx3p5A+8/Gl4tlVS yuK/x2WzMQSOTdYIrqkyK3tFNTPT3+9je0ROcSwwjUSc8it3ro7MW7NmQhepcGBz8tyJ 2rnC4WZhg96OsdZvfNuDQbU8hthh6un8Q/RE3DJv1sAe+iopnDA3JtZVGw+ig0vGAHwZ peGFcpLgc7EH36YSI4TcEdIrkXHJcrjzDdD56qU1HcmEw20p2KHyXNwfGvTUbh9J5tA4 ry2g== 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=ykzsPmJzHV2IQsa9lDH0qrBL76zqiLN8cDmEju7KFvI=; b=ggcDeM5ihE28BbbEnRdEP8Nsq/a4JlEWDhxGF21F2FBy6/O/LgGekttpmY7dikIk4e Hb1pwsA7P637ietdR8WvCi524jdXzhzn8hCGX629OA0Dw4XSiMuh6XjSq1h+peuCQE1Z vWOt+jNXyREaZOhDY1e/Buc1XeHjPl4SGlOk0X7A0VTlCdbDijQc/S5v5WTkA5hV4BvZ ZION48txrXvnQ2IpiRvLa3yrh+eM5eGxmCk05HBAX9LQ4Sv/FNTHYFWmOtStHs6EWcWU T4srzur52sKVH1ITgCqOXxl/Q4PM09J9ualeZs5e6DDsdLeCo/soY+dmXVd0iIqBsOLH vjsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="eb/TLW80"; 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 w71si1333593pgd.43.2022.01.24.12.43.05; Mon, 24 Jan 2022 12:43:25 -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="eb/TLW80"; 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 S1346845AbiAXUBC (ORCPT + 99 others); Mon, 24 Jan 2022 15:01:02 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59476 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345635AbiAXTi1 (ORCPT ); Mon, 24 Jan 2022 14:38:27 -0500 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 899F8B81250; Mon, 24 Jan 2022 19:38:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75D27C33A1C; Mon, 24 Jan 2022 19:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053103; bh=n3NJfTp/Pp/vZAidsmeEXWJbiKjAhzMri3BOT8j4izQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eb/TLW80kcVwjGSQZuZyX7NphQuOpdp2yrtV2ANz0G0P2rvkxbfVUXwrGi/4ND9vq BZbRm2aRqnLwbsQLIfOUkxUISQgsq+0gZicFZ36yLaqlm0zLh9zacCT5Orv/NSzpR3 ourm7WXkjZzhdEabKKfQe7GWfkuplFp/jq2h3MuU= 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.4 245/320] rpmsg: core: Clean up resources on announce_create failure. Date: Mon, 24 Jan 2022 19:43:49 +0100 Message-Id: <20220124184002.321537839@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 @@ -473,13 +473,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; }