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 5340D749A for ; Thu, 12 Jan 2023 14:04:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97207C433D2; Thu, 12 Jan 2023 14:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673532280; bh=GPQqmx4jNPwa2xyzfJgojFn/OpoC/W1FiKLUnUWcDMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z735VC8M5CM8E5fe2Dhfm5kgn4EWg13mB68fJBC08DWHFTRKz2yTJYJMLAhkcG1lZ dp08l+IGsVA9yXweqOrLhHMz/bl15NxxrWQ/rShI/9AOzgl8Pb023L4HL2D03gBs6z YDEmi5H1WmgGN+UkAQ/x1wUYkcxX3JF6zi3BUhrU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cai Xinchen , Alexandre Bounine , Dan Carpenter , Jakob Koschel , John Hubbard , Matt Porter , Wang Weiyang , Yang Yingliang , Andrew Morton , Sasha Levin Subject: [PATCH 5.10 102/783] rapidio: devices: fix missing put_device in mport_cdev_open Date: Thu, 12 Jan 2023 14:46:58 +0100 Message-Id: <20230112135528.932483309@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112135524.143670746@linuxfoundation.org> References: <20230112135524.143670746@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Cai Xinchen [ Upstream commit d5b6e6eba3af11cb2a2791fa36a2524990fcde1a ] When kfifo_alloc fails, the refcount of chdev->dev is left incremental. We should use put_device(&chdev->dev) to decrease the ref count of chdev->dev to avoid refcount leak. Link: https://lkml.kernel.org/r/20221203085721.13146-1-caixinchen1@huawei.com Fixes: e8de370188d0 ("rapidio: add mport char device driver") Signed-off-by: Cai Xinchen Cc: Alexandre Bounine Cc: Dan Carpenter Cc: Jakob Koschel Cc: John Hubbard Cc: Matt Porter Cc: Wang Weiyang Cc: Yang Yingliang Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- drivers/rapidio/devices/rio_mport_cdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c index b8c09eaa23b5..5ac2dc1e2abd 100644 --- a/drivers/rapidio/devices/rio_mport_cdev.c +++ b/drivers/rapidio/devices/rio_mport_cdev.c @@ -1911,6 +1911,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp) sizeof(struct rio_event) * MPORT_EVENT_DEPTH, GFP_KERNEL); if (ret < 0) { + put_device(&chdev->dev); dev_err(&chdev->dev, DRV_NAME ": kfifo_alloc failed\n"); ret = -ENOMEM; goto err_fifo; -- 2.35.1