Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3092019rwb; Mon, 15 Aug 2022 17:56:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR4aF6Rt4F+9dxme1OpS2YyOc0pRjvKVDkp1lOY6hX2kE3jujgW0aZGn2hbBhVpSKLbfovWx X-Received: by 2002:a17:907:3f11:b0:731:57ed:3aea with SMTP id hq17-20020a1709073f1100b0073157ed3aeamr11686704ejc.432.1660611366029; Mon, 15 Aug 2022 17:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611366; cv=none; d=google.com; s=arc-20160816; b=aI86qLyoIyvE+fEnpJm3dxPcXeu4uGQ+z7q6YqfLm/FjOmRQEKYpc1YlhzbILZm7zc tWX9PnHu/ZgTgs1xQad/B1B9yGTPqv3zNq5yCQ/B43zjEYtqhUphrm4n0kLxY/to5XEF w/ayL29tvMwKVeRtpIPnv8i5jOARv1m70xuwWf0JZe9Xfz2LFaui9Aym+6k5WpNYgXy3 ab49rR4bTTbhLaOfaN15hbIClX6GL0vv7/c+QHyLa3m2l2tvUgWeUX8vXi8CRbPP6q7D 4jHMe8ChCXQRBDi5wVxf6g38CbSBiFxrc5+w+wigDWNi88REniHnY0CMtqly/SZWnyvT aF2Q== 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=cO8d4U6UfPgi+QdG8kcbQUYRnKg7j4fLlielsk9zKcY=; b=o+XYxmaoZIISU+hgdqRxQRxk9kZkkEGxp4Y4mfif+gDi7zHxuGsopHfFwOJ5x/OKRo hL/8Y42xvK82xDNcyX5QCAl2Dt+KR5HmAid0QZHCjDf6CqOsHMWUm57U1m5boaE+5haP BjDVamr6cWMHnzfsmlDJF55A1Or9eFRgp/Tt5y/Q1qROVhmv5DfdijQ8bBOZYlALP/c1 RaEsCrpRVdgG0Yn1R6lQ00+svro+iFuAWEuYMi3QIFuaQ1f8MdiEsw9/3gpIcRGN8WwJ /ivWGpIio2bPomh37MvvEVClJVuHxqH+UIZtWb9JaMX2q2L8Z71eDiCeOiP5M2UH5U63 hOJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2vcABcmY; 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 gn23-20020a1709070d1700b007315c6e038esi8726824ejc.994.2022.08.15.17.55.39; Mon, 15 Aug 2022 17:56:06 -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=2vcABcmY; 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 S241292AbiHPAkP (ORCPT + 99 others); Mon, 15 Aug 2022 20:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245197AbiHPAjR (ORCPT ); Mon, 15 Aug 2022 20:39:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CEF518C470; Mon, 15 Aug 2022 13:38:33 -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 8C573B80EAD; Mon, 15 Aug 2022 20:38:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6809C433D6; Mon, 15 Aug 2022 20:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595910; bh=Tz6s7IBJFW1EdgkP4qnQqoUkNTXXGbMItPG58G6NuaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2vcABcmYUsU0lIkMB0QkQtrA7Hgr1xSUy7DkrLFkM8WNNJ3G+VsSS5lyb0SRhM4Cs rp2VKtCRPi5KXfl1X2Kmglh0BpKYq3JnOUsT4b16884+fFVY9S00SOWDMcwBd8cdRp 6a2B3WPAFoX8KEw77LTiUcE4TrrgIBKfwd5gcbro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Hangyu Hua , Mathieu Poirier , Sasha Levin Subject: [PATCH 5.19 0914/1157] rpmsg: Fix possible refcount leak in rpmsg_register_device_override() Date: Mon, 15 Aug 2022 20:04:30 +0200 Message-Id: <20220815180516.015601862@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Hangyu Hua [ Upstream commit d7bd416d35121c95fe47330e09a5c04adbc5f928 ] 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: Sasha Levin --- drivers/rpmsg/rpmsg_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 290c1f02da10..5a47cad89fdc 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -618,6 +618,7 @@ int rpmsg_register_device_override(struct rpmsg_device *rpdev, strlen(driver_override)); if (ret) { dev_err(dev, "device_set_override failed: %d\n", ret); + put_device(dev); return ret; } } -- 2.35.1