Hi,
Le mercredi 11 mars 2026 à 01:35 +0530, Sanjay Chitroda a écrit :
From: Sanjay Chitroda sanjayembeddedse@gmail.com
Replace manual cleanup logic with __free attribute from cleanup.h. This removes explicit kfree() calls and simplifies the error handling paths.
No functional change intended for kmalloc().
While I like auto cleanup, I think consistency is key. kmalloc is a tiny little dot in the sea here. Most of our leaks are in probe() error handling. In v4l2, you find a log of init() with matching releas() call, which get constantly forgotton. My suggestion would be to focus on one driver at the time, not kmalloc across the kernel, and try and "port" these driver to consistently use the cleanup function. This should also come with usage of quard() as its the same objective.
You goal should be to return at any point in the function without risking of leaving lock/spinlock held or leaving memory.
Marking as change requested the codec releated patches in this series.
Nicolas
Signed-off-by: Sanjay Chitroda sanjayembeddedse@gmail.com
.../media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c index 2da11521fc7b..3184939f793a 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c @@ -96,7 +96,7 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, int total_len = 200 * (dbgfs->inst_count == 0 ? 1 : dbgfs-
inst_count);
int used_len = 0, curr_len, ret; bool dbgfs_index[MTK_VDEC_DBGFS_MAX] = {0};
- char *buf = kmalloc(total_len, GFP_KERNEL);
- char *buf __free(kfree) = kmalloc(total_len, GFP_KERNEL);
if (!buf) return -ENOMEM; @@ -134,7 +134,6 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, mutex_unlock(&dbgfs->dbgfs_lock); read_buffer: ret = simple_read_from_buffer(ubuf, count, ppos, buf, used_len);
- kfree(buf);
return ret; }