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 4C3B228B7EA; Wed, 4 Feb 2026 14:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216598; cv=none; b=qJOfzC0WrXkpW9bPaxid9uLqd2/VrjGRRuliUBzP1GB8S9b1iizabYyMl1TF2Hf4z6jA6NHJV06bWniXwxXfsk/Xoq/ncOdYDWOlYoGxWz4FxuxzGtRfdeGDRPYfO6VEN04hqiQJLnXd2CipcMVnI4dPw2SNw1vGBK+dCwmFjBA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770216598; c=relaxed/simple; bh=tsfRM2qTkn/GPTxFqfSiPtq38Dm6/3dhXEmZ+DjUygU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tWCOs7hZg4JUb6V0vYcjpDANC6UcfDQgT++LzyZlQ1R3uIf+1Sd5b0+6uKfyBbB9FnvIl51ZvC+YxW98ugpU/N2G0VBcCVjV4Ig15CYairkLtLLQUStTHn/t0CzEJtS9a+jeiupFAv/KIFg4YuoFiKop8RhsfMp6yG+InF/GbyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G3gyWjQE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="G3gyWjQE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCE09C4CEF7; Wed, 4 Feb 2026 14:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770216598; bh=tsfRM2qTkn/GPTxFqfSiPtq38Dm6/3dhXEmZ+DjUygU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3gyWjQELlqJUXSanUk9TDEBWHuK1ZuEZDcnlGK2iBP3j8O3TLiEM/3QX+jt0JwKM o1C13TC1xycWlU6uAzNBwXB7qccAdQ8aVGIBLhVtqDsFANPR36iTdCjLZ+OeHj8DR1 uusCG16ki/dVbeVCqIaFSvIKkWfD+mIvZ0rnuw2Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexander Shishkin , Ma Ke , Johan Hovold Subject: [PATCH 5.10 101/161] intel_th: fix device leak on output open() Date: Wed, 4 Feb 2026 15:39:24 +0100 Message-ID: <20260204143855.380621202@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260204143851.755002596@linuxfoundation.org> References: <20260204143851.755002596@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 95fc36a234da24bbc5f476f8104a5a15f99ed3e3 upstream. Make sure to drop the reference taken when looking up the th device during output device open() on errors and on close(). Note that a recent commit fixed the leak in a couple of open() error paths but not all of them, and the reference is still leaking on successful open(). Fixes: 39f4034693b7 ("intel_th: Add driver infrastructure for Intel(R) Trace Hub devices") Fixes: 6d5925b667e4 ("intel_th: Fix error handling in intel_th_output_open") Cc: stable@vger.kernel.org # 4.4: 6d5925b667e4 Cc: Alexander Shishkin Cc: Ma Ke Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20251208153524.68637-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/intel_th/core.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -810,9 +810,12 @@ static int intel_th_output_open(struct i int err; dev = bus_find_device_by_devt(&intel_th_bus, inode->i_rdev); - if (!dev || !dev->driver) { + if (!dev) + return -ENODEV; + + if (!dev->driver) { err = -ENODEV; - goto out_no_device; + goto out_put_device; } thdrv = to_intel_th_driver(dev->driver); @@ -836,12 +839,22 @@ static int intel_th_output_open(struct i out_put_device: put_device(dev); -out_no_device: + return err; } +static int intel_th_output_release(struct inode *inode, struct file *file) +{ + struct intel_th_device *thdev = file->private_data; + + put_device(&thdev->dev); + + return 0; +} + static const struct file_operations intel_th_output_fops = { .open = intel_th_output_open, + .release = intel_th_output_release, .llseek = noop_llseek, };