From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EC1123762 for ; Mon, 6 Nov 2023 13:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="N2DzbWCN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AAC5C433C8; Mon, 6 Nov 2023 13:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699277010; bh=IJjcX6ieEg8ro9WUlQgUH/GHcNDuiCVSu40SpFgQhdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N2DzbWCNoAydnrkrBMXyMrYlPfM0zoY9col6f4YFL9HAYkdT59Q2yIQe1R/j0Gzog Z7usMhZ9/LEXnjGXqOnv3ZYE41y3oSwMmi1x20PZvgx3yjHI7iLjSSdgmx7aY7A0OT fYKEdsdm7Xx99INivlNKkOeP1exFBHFYfsrdOoxU= From: Greg Kroah-Hartman To: stable@vger.kernel.org, lee@kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Krzysztof Kozlowski , Hangyu Hua , Mathieu Poirier Subject: [PATCH 5.4 49/74] rpmsg: Fix possible refcount leak in rpmsg_register_device_override() Date: Mon, 6 Nov 2023 14:04:09 +0100 Message-ID: <20231106130303.424761775@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106130301.687882731@linuxfoundation.org> References: <20231106130301.687882731@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hangyu Hua commit d7bd416d35121c95fe47330e09a5c04adbc5f928 upstream. rpmsg_register_device_override need to call put_device to free vch when driver_set_override fails. Fix this by adding a put_device() to the error path. Fixes: bb17d110cbf2 ("rpmsg: Fix calling device_lock() on non-initialized device") Reviewed-by: Krzysztof Kozlowski Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220624024120.11576-1-hbh25y@gmail.com Signed-off-by: Mathieu Poirier Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/rpmsg/rpmsg_core.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -551,6 +551,7 @@ int rpmsg_register_device_override(struc strlen(driver_override)); if (ret) { dev_err(dev, "device_set_override failed: %d\n", ret); + put_device(dev); return ret; } }