From nobody Mon Feb 9 12:29:17 2026 Received: from mail-m155101.qiye.163.com (mail-m155101.qiye.163.com [101.71.155.101]) (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 847583242A3; Tue, 3 Feb 2026 13:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.71.155.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770127034; cv=none; b=jqvGyp6sGjX91/SlnaHXs2melsFyAGF564Jt6sgxvb03T9y+6GCQkgj0TZebPVHsU3HoSUX6ZwA3Ut6sGSVQPnHNaH8CpUwyZCTgxyIq3qFOX0n6KKXNA88eqaW5pjEgy86auD/tpUOcU7L0mrB933OW20euBQw+KuQ+t5v05UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770127034; c=relaxed/simple; bh=BwqShFDfcMmDz5N7+ay0hHwJvJGX7S3V/13p3LSN2gY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EHTsMFENEWdf/X/yrfZj420bTz9pOgOwPa9kC7l34THhEG1oaeLe29MH6MW6uB15H6X7J4HKreqcl46kJeE3rGQYlqTExfAsC32SYHYk9piAYz1A8pzs5kFQ158if+s8ev3HghPnrev1zTLz7BxuetO3p32exWJhj0IjI14Zr58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=AI2Hp2RB; arc=none smtp.client-ip=101.71.155.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="AI2Hp2RB" Received: from LAPTOP-N070L597.localdomain (unknown [222.191.246.242]) by smtp.qiye.163.com (Hmail) with ESMTP id 32f8a26bc; Tue, 3 Feb 2026 21:57:01 +0800 (GMT+08:00) From: Zilin Guan To: andy.shevchenko@gmail.com Cc: andy@kernel.org, gregkh@linuxfoundation.org, hansg@kernel.org, hverkuil@kernel.org, jianhao.xu@seu.edu.cn, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, mchehab@kernel.org, sakari.ailus@linux.intel.com, zilin@seu.edu.cn Subject: [PATCH v3] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table() Date: Tue, 3 Feb 2026 13:56:59 +0000 Message-Id: <20260203135659.3801028-1-zilin@seu.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9c23cad61d03a1kunm958866412a5464 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDT0wfVh4fGU4fTh4YGU0YGlYeHw5VEwETFhoSFy QUDg9ZV1kYEgtZQVlJSUlVSkJKVUlPTVVJT0lZV1kWGg8SFR0UWUFZT0tIVUpLSUhOQ0NVSktLVU tZBg++ DKIM-Signature: a=rsa-sha256; b=AI2Hp2RBCq3KoDO2B0vVtgtCmH+GCHaeLf33WrEXV5lGCzzihste9wS+JKxzoqZ2/u9YzlMCR/xQVodSuBPwGaX0CSso/QEMSj2b34TY8X4ee/g5sqtEKB3LBGsJMPdfjJDMa4W7KLVI5ji4zlE8weZHiZEd1OIKPGeC15TuVrA=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=u7nukV5y5VSMfR+Ba85BiRxAUTxFcI9vHyvr50p2Dvw=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" atomisp_v4l2_framebuffer_to_css_frame() allocates memory for temporary variable raw_black_frame, which must be released via ia_css_frame_free() before the function returns. However, if sh_css_set_black_frame() fails, the function returns immediately without performing this cleanup, leading to a memory leak. Fix this by assigning the return value of sh_css_set_black_frame() to ret. This ensures that the error code is propagated while allowing the execution to fall through to the ia_css_frame_free() cleanup call. The bug was originally detected on v6.13-rc1 using an experimental static analysis tool we are developing, and we have verified that the issue persists in the latest mainline kernel. The tool is based on the LLVM framework and is specifically designed to detect memory management issues. It is currently under active development and not yet publicly available. We performed build testing on x86_64 with allyesconfig. Since triggering this error path in atomisp requires specific Intel Atom ISP hardware and firmware, we were unable to perform runtime testing and instead verified the fix according to the code logic. Fixes: 85b606e02ad7 ("media: atomisp: get rid of a bunch of other wrappers") Suggested-by: Andy Shevchenko Signed-off-by: Zilin Guan Reviewed-by: Andy Shevchenko --- Changes in v3: - Assign the result of sh_css_set_black_frame() to ret instead of hardcoding -ENOMEM. Changes in v2: - Add detailed explanation about the tool and verification method. drivers/staging/media/atomisp/pci/atomisp_cmd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/stag= ing/media/atomisp/pci/atomisp_cmd.c index 3a4eb4f6d3be..ae9c4dc8a44b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3367,10 +3367,8 @@ int atomisp_fixed_pattern_table(struct atomisp_sub_d= evice *asd, if (ret) return ret; =20 - if (sh_css_set_black_frame(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].= stream, - raw_black_frame) !=3D 0) - return -ENOMEM; - + ret =3D sh_css_set_black_frame(asd->stream_env[ATOMISP_INPUT_STREAM_GENER= AL].stream, + raw_black_frame); ia_css_frame_free(raw_black_frame); return ret; } --=20 2.34.1