From: syzbot <syzbot+acc3b75c010446ad403f@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH 1/2] media: vidtv: fix memory leak in vidtv_psi_desc_clone() on allocation failure
Date: Tue, 26 May 2026 03:04:41 -0700 [thread overview]
Message-ID: <6a157039.170a0220.22ae77.0015.GAE@google.com> (raw)
In-Reply-To: <6a150a33.2b0a0220.185dbd.0004.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH 1/2] media: vidtv: fix memory leak in vidtv_psi_desc_clone() on allocation failure
Author: zhanghaotian@uniontech.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
vidtv_psi_desc_clone() builds a linked list of cloned descriptors by
calling descriptor init functions (e.g. vidtv_psi_service_desc_init())
that chain new entries into the accumulated "head" via
vidtv_psi_desc_chain(). When any init function or kmemdup() fails
inside the while loop, the function returns NULL without freeing the
already-built portion of head, leaking memory.
Fix this by calling vidtv_psi_desc_destroy(head) before returning NULL
in both failure paths.
Reported-by: syzbot+acc3b75c010446ad403f@syzkaller.appspotmail.com
Signed-off-by: zhanghaotian <zhanghaotian@uniontech.com>
---
drivers/media/test-drivers/vidtv/vidtv_psi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/test-drivers/vidtv/vidtv_psi.c
index 1b6225d65..7f38011ae 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_psi.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c
@@ -481,11 +481,11 @@ struct vidtv_psi_desc *vidtv_psi_desc_clone(struct vidtv_psi_desc *desc)
default:
curr = kmemdup(desc, sizeof(*desc) + desc->length, GFP_KERNEL);
if (!curr)
- return NULL;
+ goto free_head;
}
if (!curr)
- return NULL;
+ goto free_head;
curr->next = NULL;
if (!head)
@@ -498,6 +498,10 @@ struct vidtv_psi_desc *vidtv_psi_desc_clone(struct vidtv_psi_desc *desc)
}
return head;
+
+free_head:
+ vidtv_psi_desc_destroy(head);
+ return NULL;
}
void vidtv_psi_desc_destroy(struct vidtv_psi_desc *desc)
--
2.30.2
next prev parent reply other threads:[~2026-05-26 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 2:49 [syzbot] [media?] memory leak in vidtv_psi_service_desc_init (2) syzbot
2026-05-26 9:29 ` Forwarded: [PATCH 0/2] media: vidtv: fix memory leak in vidtv_psi_desc_clone syzbot
2026-05-26 10:04 ` syzbot [this message]
2026-05-26 10:04 ` Forwarded: [PATCH 2/2] media: vidtv: fix error handling in channel SI init functions syzbot
2026-05-26 12:49 ` Forwarded: [PATCH] media: vidtv: fix memory leak by cleaning up mux in bridge_remove syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a157039.170a0220.22ae77.0015.GAE@google.com \
--to=syzbot+acc3b75c010446ad403f@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®