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 7284035C188; Fri, 9 Jan 2026 12:46:21 +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=1767962781; cv=none; b=hWnLWiT3MWRRxPOpNcUPQNz94m8VdV6ebxSo0HvV1m51Ni+nKnW4euMGAePMKS7mfR4Kx2+Q6fDMJzAE9FoufgXbq7QJn0zBzpKwV1G8PorKEaSm6cGWiEgXqkNKWCH1gtGLjpZIGzHXKPRbO2uZ4F1x0HXb2UBWg7qGFQp25GQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767962781; c=relaxed/simple; bh=JgkPr2G3E+MOBAlWdh4ylMOjYLwRi+mF6mJQacj73vQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cBcPYoLyGjS4kx6N0+7XHAZybJ2FIwEZ5eN0XB163QHmXL4HSUBMIHuAp6cyfadx7DvR6vfNcM6ONAnuntyBxWbAdkiu+FdMO/VGIpvRpbm8VVRdpc21XKxS3srsB3qUVI3V/AYDfpQ3hg5MjYkBhfpHqnhyfwFRwV2skwNXV3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bz0Vmg4R; 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="Bz0Vmg4R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01C1DC4CEF1; Fri, 9 Jan 2026 12:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767962781; bh=JgkPr2G3E+MOBAlWdh4ylMOjYLwRi+mF6mJQacj73vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bz0Vmg4RNixprQG3s+T7uquK8in5EDexjF9U5Mp4E9miJKkoBt4wYoD2XdUT+BTzk ARR1uR5KHCZnGPukeLDW8drMSbnvJmjyJTh9jpmGCaWESmMLlWfDtv0/Lye9Ns0AIs HjkVdJsY0tGHcitsmAca+FJpOYLGc6EWYqUbSsjY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haotian Zhang , Marek Szyprowski , Hans Verkuil Subject: [PATCH 6.1 484/634] media: videobuf2: Fix device reference leak in vb2_dc_alloc error path Date: Fri, 9 Jan 2026 12:42:42 +0100 Message-ID: <20260109112135.757268566@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112117.407257400@linuxfoundation.org> References: <20260109112117.407257400@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haotian Zhang commit 94de23a9aa487d7c1372efb161721d7949a177ae upstream. In vb2_dc_alloc(), get_device() is called to increment the device reference count. However, if subsequent DMA allocation fails (vb2_dc_alloc_coherent or vb2_dc_alloc_non_coherent returns error), the function returns without calling put_device(), causing a device reference leak. Add put_device() call in the error path before kfree() to properly release the device reference acquired earlier. Fixes: de27891f675e ("media: videobuf2: handle non-contiguous DMA allocations") Cc: stable@vger.kernel.org Signed-off-by: Haotian Zhang Reviewed-by: Marek Szyprowski Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c @@ -258,6 +258,7 @@ static void *vb2_dc_alloc(struct vb2_buf if (ret) { dev_err(dev, "dma alloc of size %lu failed\n", size); + put_device(buf->dev); kfree(buf); return ERR_PTR(-ENOMEM); }