From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (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 A3C803B1035 for ; Mon, 8 Jun 2026 08:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908714; cv=none; b=WtKBCvDZkDomD0SmMRY5WKHJAIq40jmatS0JMcPQCHCGcnYttf7K/qgEt7F8gheGkQT6xojQyOxbvWg85BF1thV0Uk9CUb5N4F44q1GxX26iEIB6nHMfVJsfustO/k89Xyg8fR8nZ+bJihXPLSoQwo+je+/Yw1J6s4VwKRjbStQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908714; c=relaxed/simple; bh=KxzcZczBnWtnF71WrvbJ931DN27De2S8SoNvlQedRC8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SyvPWbyM1tPpuO7MKRSjbfkPg6vWUqtXiSFRqPF1iN52/ONgqykKbDtAtmH8WtMmuzYP9BIG2W1iM6KJYwi1r+u9n4OgBLx01TKhfaZDpM64ELSzsyykgqZ9irv5jE4vAkhhyhF8jWzlUYl3ioe8pkDzXhjLF4BXUhx/F9WgEbc= 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=siXA3k1X; arc=none smtp.client-ip=209.85.160.177 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="siXA3k1X" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-5177945a279so44025061cf.0 for ; Mon, 08 Jun 2026 01:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780908712; x=1781513512; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=O248v2PloCfOKOL55ryzQvPbQCl4x0VQe69JsI4A4+Y=; b=siXA3k1XawNuW6BznvuxXB+AHCIDx5YfIDJQOxl9N9opCtsynMtj7R5RLEZmbZ7LM/ 4Y/GRqImJ4b6daEGGsyO5lEefbua1McPm/XsgUB+4zVYMvH0RYusnk3SFohVcOwj+332 LDhix7taLyG4MUMU7uY4VvsEwp/JP1Snibp8klCYgK0d7KcJWQJGT1ccITrgaI8VZmQw 07Vp+eKnHKIHQhzhsrJyAfBHViAQ72Q6Key5eg9hFFBnMdsbO5RhBf/jlhr0W0PM1cVt vjFDFbZ2v9VyF5/iB7Bjn3NJgUgYoIZmYMaS1KHIiE/3Ku6AAOCYc6VfJNF4+pmmS2aj 7/Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780908712; x=1781513512; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O248v2PloCfOKOL55ryzQvPbQCl4x0VQe69JsI4A4+Y=; b=sBylqwTIPd+J4knVllLzXLYsCHlln5KQX5iFHw0qo2IMYWVJMIeBJvBPSQWdKQE9WH 04s+80/KIlhr2jt9tEyu4fnaOfnLlRzzmHUkOmVGr0/NW0XJFrCMewOWU6ZO0eR1l13L XEJMAORq264WfOpIArVMvvRdRWcxb3/2QMeK5CUvqdBd709vzMGeryWMiR0NmIEHYMSh gfCTNiahiNVtQ6UscyV0+/FSNKAyqxPQy00YDpBmBpHwhIAbKPPAFDtO/YvhpWzm2L1d MlGTznZRgaX5gd/ANjS/5ew63d9unc5QZ7QbS4OQU799Fup9mpxyNt+C2nJ0IscO83W5 R/TA== X-Forwarded-Encrypted: i=1; AFNElJ914dkSmOW20ccgYKbS8Bxa8k00WbwqIps3HF6IukirVmKBRFsVUi0wz4CFY7Ff3ZrB6hEHv6e3LZ3lsHw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxe0Dhn6mOgMXiER+t0DnNisACtyoeFUnaO9Vu8JbjcRV7IqlMk hystEtfqEw0Es/xPp+JtBtkvm4WhPlAL90bLdtn2kJkCT01BvXCVSMgU X-Gm-Gg: Acq92OFM3BS+gxEQ2fGHF8CjkMRKw20wmT/gGhCMNvDWXaEbyc4P4+6KCHMwwWGGtnN WUveKSK66oOGrvAAmWhTUky3jof8RxNtrEZVazdN4LREnZ7Urp2GLZKM5N0LDjJ/WzMGJrsfTq/ Uldq311FA336Xg6v5uV4k8RuvfioYKY1kx59PBDiNgZWssCN98pk/rFhFwOPWJgkm8k7cpdqFB4 P5yaSoOT0CsWgrGhZD+Xac6BZoubeEIYN6setao/i+aY95q5QQ3jm40ApMrqBpczVVg/Kcq0Ehq J5LdZtzd1xaIAhC+aeaAwOW+MLvO3fYMETadRSWO0G2U2GS2RHOjSONddfwtjGFADGIuMefj4bg ugwF9sxsJVFoEbgd9H8+PN5UXxRVMPLrw0D7M7B9SNoiipn6ggYyk5KXcJ+bNIGKLfTip/O5Bp5 UlGRIs1X3BcZ50TnTq+QNE2DA4fp9f X-Received: by 2002:a05:622a:6094:b0:516:ed02:c85d with SMTP id d75a77b69052e-51795b0e75fmr206862321cf.3.1780908712526; Mon, 08 Jun 2026 01:51:52 -0700 (PDT) Received: from localhost ([43.225.189.113]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775c08234sm149224681cf.6.2026.06.08.01.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:51:51 -0700 (PDT) Date: Mon, 8 Jun 2026 11:51:45 +0300 From: Dan Carpenter To: Dawei Feng Cc: andy@kernel.org, hansg@kernel.org, mchehab@kernel.org, sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org, abdelrahmanfekry375@gmail.com, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, jianhao.xu@seu.edu.cn, Zilin Guan Subject: Re: [PATCH] media: atomisp: Fix resource leak in atomisp_pci_probe() Message-ID: References: <20260608082706.3287831-1-dawei.feng@seu.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260608082706.3287831-1-dawei.feng@seu.edu.cn> On Mon, Jun 08, 2026 at 04:27:06PM +0800, Dawei Feng wrote: > During atomisp_pci_probe(), the ISP subdev is initialized via > atomisp_initialize_modules() prior to entity registration. If > atomisp_register_entities() fails, the current error path only > uninitializes the CSI2 modules. This leaks the subdev entity and control > handler that were previously set up by atomisp_subdev_init(). > > Fix this by calling atomisp_subdev_unregister_entities() to properly > release the subdev state on this specific error path. Later error paths > remain unchanged, as they correctly use atomisp_unregister_entities() to > handle broader cleanup after successful registration. > > The bug was first flagged by an experimental analysis tool we are > developing for kernel memory-management bugs while analyzing v6.13-rc1. > The tool is still under development and is not yet publicly available. > Manual inspection confirms that the bug is still present in v7.1-rc5. > > An x86_64 allyesconfig build showed no new warnings. As we do not have an > Intel Atom ISP platform to test with, no runtime testing was able to be > performed. > > Fixes: 9d4fa1a16b28 ("media: atomisp: cleanup directory hierarchy") > Signed-off-by: Zilin Guan > Signed-off-by: Dawei Feng > --- The code is buggy, but this isn't the right fix. Here is generally the standard way to do error handling. https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/ 1. An allocation should clean up it's own partial allocations. That should not be handled in the caller. 2. Every allocation function should have a mirror cleanup function. The atomisp_uninitialize_modules() function is just a dummy and was never actually implemented. The correct thing is to implement it. regards, dan carpenter