From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6C833E2759 for ; Tue, 10 Mar 2026 20:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773173189; cv=none; b=EvchrxvL2uF0cmjoY8HsapDWv+3052kBNcuL0Yb3KHQhkil/YWFiXWtX/HvNaAuzzs6Wh3MDg3qBOGiSV/5/jDRbOytVUhvobXtCsBu16XBIShB4BLoBycozQ6O7va9/Fr2Zl4cRmHm4i7jGLhjlU1YbNWLmqbyOB93nzL8brU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773173189; c=relaxed/simple; bh=T2a2fDI+lpfSbpuOM83tDaRUsM8l7LwGUzwFcjl1mvQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qomRd1JXSNqabMBxv4JDv/Hnkff6/uqEpMmYd3IsdJ/1MNmiwWwyGfuLNhT4J8qTcqrrwRjnWD4shWnvL/Gub1Xm/shK8aNLE/pRo/bI0SCnfeiY8ual/aTRT6eJQAlvPN3jFJbePKwVZQ8OoyJa/iaC/hEJDON5imIrRKCbd/w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D8/UgHkJ; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D8/UgHkJ" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-829ac4670c4so2908514b3a.0 for ; Tue, 10 Mar 2026 13:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773173186; x=1773777986; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7Cqt8CNmVHlobpg7w55yWqsOaWHWtGYPmo0BwNs9xzs=; b=D8/UgHkJafHXs+7lpIRGvx5RtQg2ejlHxfG12OObUUKofBx3A7aRT71Ou4NmSga6P8 DNgLJV2PULu7oaz3rnuWhpNWPsipx7JkUmH5n8yczKCB499Q4MuywD46YR4nLaii4lrH 9yjvBmPHrNWyOcxqC7HtioDLsKxsshBJDrlZt2Eq6DFBYWg6R8RzxhTpxQyqPI8sZmO6 pzaBkypgXVbv2TXpX5OVqa7ebnKKQkciA9Goe9cg4rOc/SW7BNU2PhXqSCjoOv99LQxO ME/KiGBeoOeHIs8fsLfDKS8V+SL1F8fmq15aEz+kMFEUzNJ/wO5Gff0gRALxgDKVH7oX RTKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773173186; x=1773777986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7Cqt8CNmVHlobpg7w55yWqsOaWHWtGYPmo0BwNs9xzs=; b=L2+MUyy6ChSEwlC5i1rsND7ywGtHVuiVI97/4Zx6lg1Gk4DZatqRfhGhoKsvYfmnB/ 7fqv/UI0WJ2vyO/1777dqJzaVg1QSs+/JjK9ggsjhwsNgk86gMAAfgxh3nTK+IMtReDd v9n9qLjEfGIkqoagvmmvxlkFkBMI1/0dwMEB8+4Hzs6A6ZVh3Hm+iLfiimiRZg0/MKrR a6afxF4DySzfZB+9zhp2OVOuxmolj6DmZLySa8C797tV1/T7isb7DSsYbzjE+AM8ZBD+ znVcX6VoUVfIRX4Joo82Zvlw5dJ/lzP6Xn7MNdMr92eM6ZvsNDOjEPbsUsd5P/nGgByI sSTQ== X-Forwarded-Encrypted: i=1; AJvYcCVAczhQ02kb8Zy07PV2oxcan2kKerAi+hQ0Q2eQBI8Wp3Q5t+zKGtE3Byzxr+S+bAuyvmP9DR8L8zkzml3Z@lists.linux.dev X-Gm-Message-State: AOJu0Yz9Q0BYTG5paunr0MJIEEiG/pdquXrWV8WA3vDE37k1PoveZI7J QxDM4/TaSxOznQGaSh1D2JKyCGeUVBDv0ezlE3HsoAk08XkhTCOKBRrV X-Gm-Gg: ATEYQzyOx2R/4vxuSgHyDqdovko1CpUInA57t9ASUUtNrBeLzXCwXYAdKl18B4tJ+/j 2yRd4UQ6xraFD+IChth+sVMGbQNu1XmtHSzLiF89OxuY/bhHyUhgDrsG2zzp0G5GyaNucNCyeS1 fBr6Kayl+5d6uulD3RI0PQ4Z3/8ymxZZEKoI7zp2hw15llqcaE/VAE3C1n/TP60iMmipnUuFFEs dYES3jBH7Gi4tbxwthFKTlYtuVxSCbOEjufKzqG+L+gdeAnGAtRrLQJT7d5HCEecEMdYkz8YptQ m5Tw23QICTO3J8sR22pS/7sPBsSax28NkVo/gQPbQ1iJtIDSGe/AuJ2PqYExVeI1fKaiA5aMxDc HcFk48qHD5Aqu1vwUiOX//gTTN3aJ9JUzOTfKpr5V7mENbEGyIWI9sMJVEKlvVsA2KvdFIwRGsE C/FQsjvhFr0foPVP/aQ6bQU69CaSjUd/nFyj9hCX8BlPtpWrcm X-Received: by 2002:a05:6a00:13a5:b0:824:374a:1424 with SMTP id d2e1a72fcca58-829f71b3f03mr122810b3a.58.1773173186006; Tue, 10 Mar 2026 13:06:26 -0700 (PDT) Received: from hu-ckantibh-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829f6dc2d0asm101660b3a.13.2026.03.10.13.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 13:06:25 -0700 (PDT) From: Sanjay Chitroda X-Google-Original-From: Sanjay Chitroda To: jic23@kernel.org, m.tretter@pengutronix.de, mchehab@kernel.org, p.zabel@pengutronix.de, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, pure.logic@nexus-software.ie Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, kernel@pengutronix.de, kees@kernel.org, nabijaczleweli@nabijaczleweli.xyz, marcelo.schmitt1@gmail.com, maudspierings@gocontroll.com, hverkuil+cisco@kernel.org, ribalda@chromium.org, straube.linux@gmail.com, dan.carpenter@linaro.org, lukagejak5@gmail.com, ethantidmore06@gmail.com, samasth.norway.ananda@oracle.com, karanja99erick@gmail.com, s9430939@naver.com, tglx@kernel.org, mingo@kernel.org, sun.jian.kdev@gmail.com, weibu@redadmin.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, sanjayembeddedse@gmail.com, skhan@linuxfoundation.org Subject: [PATCH 5/7] media: chips-media: coda: simplify cleanup using __free Date: Wed, 11 Mar 2026 01:35:11 +0530 Message-Id: <20260310200513.2162018-6-sanjayembedded@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260310200513.2162018-1-sanjayembedded@gmail.com> References: <20260310200513.2162018-1-sanjayembedded@gmail.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sanjay Chitroda 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()/kzalloc_obj(). Signed-off-by: Sanjay Chitroda --- .../platform/chips-media/coda/coda-bit.c | 4 +- .../platform/chips-media/coda/coda-jpeg.c | 39 +++++++------------ 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c index b0559303c40f..958e245d0698 100644 --- a/drivers/media/platform/chips-media/coda/coda-bit.c +++ b/drivers/media/platform/chips-media/coda/coda-bit.c @@ -183,19 +183,17 @@ static void coda_kfifo_sync_to_device_write(struct coda_ctx *ctx) static int coda_h264_bitstream_pad(struct coda_ctx *ctx, u32 size) { - unsigned char *buf; u32 n; if (size < 6) size = 6; - buf = kmalloc(size, GFP_KERNEL); + unsigned char *buf __free(kfree) = kmalloc(size, GFP_KERNEL); if (!buf) return -ENOMEM; coda_h264_filler_nal(size, buf); n = kfifo_in(&ctx->bitstream_fifo, buf, size); - kfree(buf); return (n < size) ? -ENOSPC : 0; } diff --git a/drivers/media/platform/chips-media/coda/coda-jpeg.c b/drivers/media/platform/chips-media/coda/coda-jpeg.c index 835225383aa1..11f2800014e5 100644 --- a/drivers/media/platform/chips-media/coda/coda-jpeg.c +++ b/drivers/media/platform/chips-media/coda/coda-jpeg.c @@ -584,16 +584,15 @@ static int coda9_jpeg_gen_enc_huff_tab(struct coda_ctx *ctx, int tab_num, { int i, j, k, lastk, si, code, maxsymbol; const u8 *bits, *huffval; - struct { - int size[256]; - int code[256]; - } *huff; static const unsigned char *huff_tabs[4] = { luma_dc, luma_ac, chroma_dc, chroma_ac, }; int ret = -EINVAL; - huff = kzalloc_obj(*huff); + struct { + int size[256]; + int code[256]; + } *huff __free(kfree) = kzalloc_obj(*huff); if (!huff) return -ENOMEM; @@ -607,7 +606,7 @@ static int coda9_jpeg_gen_enc_huff_tab(struct coda_ctx *ctx, int tab_num, for (i = 1; i <= 16; i++) { j = bits[i - 1]; if (k + j > maxsymbol) - goto out; + return ret; while (j--) huff->size[k++] = i; } @@ -623,7 +622,7 @@ static int coda9_jpeg_gen_enc_huff_tab(struct coda_ctx *ctx, int tab_num, code++; } if (code >= (1 << si)) - goto out; + return ret; code <<= 1; si++; } @@ -632,15 +631,12 @@ static int coda9_jpeg_gen_enc_huff_tab(struct coda_ctx *ctx, int tab_num, for (k = 0; k < lastk; k++) { i = huffval[k]; if (i >= maxsymbol || ehufsi[i]) - goto out; + return ret; ehufco[i] = huff->code[k]; ehufsi[i] = huff->size[k]; } - ret = 0; -out: - kfree(huff); - return ret; + return 0; } #define DC_TABLE_INDEX0 0 @@ -715,15 +711,14 @@ static int coda9_jpeg_gen_dec_huff_tab(struct coda_ctx *ctx, int tab_num) static int coda9_jpeg_load_huff_tab(struct coda_ctx *ctx) { - struct { - int size[4][256]; - int code[4][256]; - } *huff; u32 *huff_data; int i, j; int ret; - huff = kzalloc_obj(*huff); + struct { + int size[4][256]; + int code[4][256]; + } *huff __free(kfree) = kzalloc_obj(*huff); if (!huff) return -ENOMEM; @@ -732,7 +727,7 @@ static int coda9_jpeg_load_huff_tab(struct coda_ctx *ctx) ret = coda9_jpeg_gen_enc_huff_tab(ctx, i, huff->size[i], huff->code[i]); if (ret) - goto out; + return ret; } if (!ctx->params.jpeg_huff_data) { @@ -740,8 +735,7 @@ static int coda9_jpeg_load_huff_tab(struct coda_ctx *ctx) kzalloc(sizeof(u32) * CODA9_JPEG_ENC_HUFF_DATA_SIZE, GFP_KERNEL); if (!ctx->params.jpeg_huff_data) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } } huff_data = ctx->params.jpeg_huff_data; @@ -765,10 +759,7 @@ static int coda9_jpeg_load_huff_tab(struct coda_ctx *ctx) } } - ret = 0; -out: - kfree(huff); - return ret; + return 0; } static void coda9_jpeg_write_huff_tab(struct coda_ctx *ctx) -- 2.34.1