From: Biren Pandya <birenpandya@gmail.com>
To: linux-media@vger.kernel.org, mchehab@kernel.org
Cc: Biren Pandya <birenpandya@gmail.com>, Kees Cook <kees@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 17/22] media: pci: saa7134: Add missing media_entity_cleanup()
Date: Sun, 14 Jun 2026 22:25:54 +0530 [thread overview]
Message-ID: <20260614165630.3896-18-birenpandya@gmail.com> (raw)
In-Reply-To: <20260614165630.3896-1-birenpandya@gmail.com>
The media_entity_pads_init() (or media_entity_init()) function initializes
the media entity, but the driver forgets to call media_entity_cleanup()
in the error paths and remove function. Add the missing calls to fix the
API violation and prevent potential future memory leaks.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
drivers/media/pci/saa7134/saa7134-core.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 2f5b258d682b..c0e1e8ad55c8 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -798,8 +798,10 @@ static void saa7134_media_release(struct saa7134_dev *dev)
#ifdef CONFIG_MEDIA_CONTROLLER
int i;
- for (i = 0; i < SAA7134_INPUT_MAX + 1; i++)
+ for (i = 0; i < SAA7134_INPUT_MAX + 1; i++) {
media_device_unregister_entity(&dev->input_ent[i]);
+ media_entity_cleanup(&dev->input_ent[i]);
+ }
#endif
}
@@ -836,8 +838,10 @@ static void saa7134_create_entities(struct saa7134_dev *dev)
pr_err("failed to initialize demod pad!\n");
ret = media_device_register_entity(dev->media_dev, &dev->demod);
- if (ret < 0)
+ if (ret < 0) {
pr_err("failed to register demod entity!\n");
+ media_entity_cleanup(&dev->demod);
+ }
dev->decoder = &dev->demod;
} else {
@@ -904,8 +908,10 @@ static void saa7134_create_entities(struct saa7134_dev *dev)
pr_err("failed to initialize input pad[%d]!\n", i);
ret = media_device_register_entity(dev->media_dev, ent);
- if (ret < 0)
+ if (ret < 0) {
pr_err("failed to register input entity %d!\n", i);
+ media_entity_cleanup(ent);
+ }
}
/* Create input for Radio RF connector */
@@ -923,8 +929,10 @@ static void saa7134_create_entities(struct saa7134_dev *dev)
pr_err("failed to initialize input pad[%d]!\n", i);
ret = media_device_register_entity(dev->media_dev, ent);
- if (ret < 0)
+ if (ret < 0) {
pr_err("failed to register input entity %d!\n", i);
+ media_entity_cleanup(ent);
+ }
}
}
#endif
@@ -956,6 +964,7 @@ static void saa7134_unregister_video(struct saa7134_dev *dev)
vb2_video_unregister_device(dev->video_dev);
else
video_device_release(dev->video_dev);
+ media_entity_cleanup(&dev->video_dev->entity);
dev->video_dev = NULL;
}
if (dev->vbi_dev) {
@@ -963,6 +972,7 @@ static void saa7134_unregister_video(struct saa7134_dev *dev)
vb2_video_unregister_device(dev->vbi_dev);
else
video_device_release(dev->vbi_dev);
+ media_entity_cleanup(&dev->vbi_dev->entity);
dev->vbi_dev = NULL;
}
if (dev->radio_dev) {
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-06-14 16:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260614165630.3896-1-birenpandya@gmail.com>
2026-06-14 16:55 ` [PATCH 01/22] media: i2c: cx25840-core: " Biren Pandya
2026-06-14 16:55 ` [PATCH 02/22] media: i2c: max9286: " Biren Pandya
2026-06-14 16:55 ` [PATCH 03/22] media: i2c: msp3400-driver: " Biren Pandya
2026-06-14 16:55 ` [PATCH 04/22] media: i2c: mt9v011: " Biren Pandya
2026-06-14 16:55 ` [PATCH 05/22] media: i2c: saa7115: " Biren Pandya
2026-06-14 16:55 ` [PATCH 06/22] media: platform: stm32-csi: " Biren Pandya
2026-06-14 16:55 ` [PATCH 07/22] media: platform: sun4i_csi: " Biren Pandya
2026-06-14 16:55 ` [PATCH 08/22] media: platform: microchip-isc-scaler: " Biren Pandya
2026-06-14 16:55 ` [PATCH 09/22] media: platform: cdns-csi2tx: " Biren Pandya
2026-06-14 16:55 ` [PATCH 10/22] media: platform: rcar-csi2: " Biren Pandya
2026-06-14 16:55 ` [PATCH 11/22] media: platform: csisp: " Biren Pandya
2026-06-14 16:55 ` [PATCH 12/22] media: platform: rcar-core: " Biren Pandya
2026-06-14 16:55 ` [PATCH 13/22] media: platform: rzg2l-core: " Biren Pandya
2026-06-14 16:55 ` [PATCH 14/22] media: platform: cfe: " Biren Pandya
2026-06-14 16:55 ` [PATCH 15/22] media: platform: j721e-csi2rx: " Biren Pandya
2026-06-14 16:55 ` [PATCH 16/22] media: platform: hantro_drv: " Biren Pandya
2026-06-14 16:55 ` Biren Pandya [this message]
2026-06-14 16:55 ` [PATCH 18/22] media: usb: cx231xx: " Biren Pandya
2026-06-14 16:55 ` [PATCH 19/22] media: usb: em28xx: " Biren Pandya
2026-06-14 16:55 ` [PATCH 20/22] media: usb: au0828: " Biren Pandya
2026-06-14 16:55 ` [PATCH 21/22] media: usb: dvb-usb-v2: " Biren Pandya
2026-06-14 16:55 ` [PATCH 22/22] media: dvb-frontends: au8522_decoder: " Biren Pandya
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=20260614165630.3896-18-birenpandya@gmail.com \
--to=birenpandya@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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®