From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 3C45F372EF6 for ; Fri, 17 Apr 2026 08:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776413141; cv=none; b=H4lyfmUrds19yW4R92yvmw5Hfjq1MFZoSGrKauR8K8VRiET9R/xUoxGcWzOp3oL88oMNwnkFmvXbaLdbbXgnyKoG70FjWcEyr4AEz6DcSgPXOnW9B5LtXhGX6NSMvj/YdK+YS940iscmo4RctBFalrdQmG41s7TNGIsi7l2D5Uc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776413141; c=relaxed/simple; bh=1AwS8Ldg92WK4KkmlNu1UjhcVxODuBNMsNe67KvbGDg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SP6qfFqGz7NttIkkIwxNy3INHaWx3J2jFodNvDb88MJHNbNvsmcPl9Kxa4X7usypYyROh/0CBnzRjMrvxINQj6axz722xrMKLsrHO/KwmHq5QyGUeH3I480SMjsRTnE7bfxJ0xiVDADYq3/aP6NNuOCC1WXb4GskRNpdjILG/64= 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=fvXfTkxP; arc=none smtp.client-ip=209.85.128.43 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="fvXfTkxP" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-488b8efed61so4148795e9.1 for ; Fri, 17 Apr 2026 01:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776413139; x=1777017939; 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=GujTxUaku0DnUDB+OcwhQi4lfujIDMhc7CTwSfLTqrM=; b=fvXfTkxP/EnFWfPP5IYRcG0+toW+tFbHsCiKhIW65QwtZosdXIzKkG6i5QYlptndr2 1q5xjqjLhzthsP6yf79LeiMLOFShaAZRpK98/vPO/uCcl3jxS245DfvhtYTtpdYoNMKM wHEA8IhZuef9lkVQOxscBWCx4o9LmeiCllGJlKIUd4hZQU+0mTezfskb7DAku8VAdogi cO3cJLDWD+Ss4aq751vBEgKhBCoFzEdEKGCpQGCyIPpaJRUs5stD+84sFXzoLNND6I9d Ca3TkZT3kJF5wz/TYnULrZgJLe5YIwj2Ax73I7kTobL+QxWMcONpC6HeFxSX38SLqc13 +UQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776413139; x=1777017939; 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=GujTxUaku0DnUDB+OcwhQi4lfujIDMhc7CTwSfLTqrM=; b=q9Jlz4QW3HLCsD5AyG6XyqfRlhWRiUPNX0xzajTMqs+VtQlYKNTkrIkZIsOSjenk5h /u8BGXNgJZf5FG8niZKuuttR06ZECXZlu4Swm0Yf9ACJ1lJOf/QRmGA3mp3k8iqpq41b kOj4dPxt89QpuRrIsH3Cvv7yZk9IMRkYmRTBaHI65SQYmmXmWuD2imVAjIAaVISM0lNj RFbcrvwDbxHSYSr+qI+I2nnsNUZfBKn8NEAROMbrKQnNv+4/GCb/u2vae9dYucr7df8e JLaE+ptJbVqScY6J+hpkMYXvr+o0BYbf+egxmi2sL/QEHy1iNQveJNLBPh9GwQl32pER 0K/w== X-Forwarded-Encrypted: i=1; AFNElJ8n8FsKcK1L2Tmk8ej7ux1XqgoXlfoZj1a8p2GOuVViuYUQgNNSGdB/va7sCpBjzcOARi+bes2LqIyQBn8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3zlOme3FJ4EJRDOl8T3DxPIvZxzwqOwk+4NtNiKYbq612GhXo kwSzU8Hd0/jwggnVIFLAW3TAR9VHO6DEFuQ2ZPeY0dU15EKRRsRbGo+z X-Gm-Gg: AeBDiesGN3DH5S/NMHax3dNb38HMxVDSC48nFnea+Pj+UTZ1ET5l8nXqp0+D3CEaf32 Vo+fLL1rd59d/CZdIQ9qsRBGbTqWWRxZKHrbPGKci5Y7hxd0m8hkSWFmviRipNKK0CA7UtgRMV0 hTA0uOsDQBu9PGNIK/8FI32i6ZmSr60Cjnw02gJVXuI3bm3NTXz5qT7qLQ/DSMHZKjVqoX8nNOv SJB3/qVd2YrbxpFkZyoYJHrWULIxZ0Ba153oChwdS3yhhdVCW9jh+qGTpQvVI6h4a3RJknA6YFB UEwWUuc0L6D+B16A2tCOGtrECdBR1GAltqg3miOUxQ0a4GM9AeQJv4fH6OrnGZVB+CwCNOdQB4h sbiKUJ7nLtk4lSYBC7gLcsZ1D22YO5ARHtCDWcSrDWYhHq+EiIgUSjHkp/Kl3/JMzM/ueahjeJK kUwjLo2hWdQAoWgWfz9vfra5absAolFg== X-Received: by 2002:a05:600c:870e:b0:488:aa33:dc8f with SMTP id 5b1f17b1804b1-488fb84ffb8mr22012425e9.0.1776413138495; Fri, 17 Apr 2026 01:05:38 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1070bfsm25752445e9.7.2026.04.17.01.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 01:05:37 -0700 (PDT) Date: Fri, 17 Apr 2026 11:05:34 +0300 From: Dan Carpenter To: Huihui Huang Cc: Sakari Ailus , Mauro Carvalho Chehab , Bingbu Cao , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] staging: media: ipu7: fix boot_config leak on queue_mem failure Message-ID: References: <20260416074800.2493565-1-hhhuang@smu.edu.sg> <20260417073939.2686170-1-hhhuang@smu.edu.sg> 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: On Fri, Apr 17, 2026 at 11:01:29AM +0300, Dan Carpenter wrote: > On Fri, Apr 17, 2026 at 03:39:39PM +0800, Huihui Huang wrote: > > There is a memory leak in drivers/staging/media/ipu7/ipu7-boot.c. > > > > In ipu7_boot_init_boot_config(), boot_config is allocated by > > ipu7_dma_alloc(). If the second ipu7_dma_alloc() for queue_mem fails, > > the function returns -ENOMEM without freeing the previously allocated > > boot_config. > > > > Add the missing ipu7_dma_free() call before returning on the error > > path. > > > > Signed-off-by: Huihui Huang > > --- > > v2: Reword commit message in imperative mood. Remove unnecessary > > NULL assignment on the error path. > > --- > > drivers/staging/media/ipu7/ipu7-boot.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/staging/media/ipu7/ipu7-boot.c b/drivers/staging/media/ipu7/ipu7-boot.c > > index d7901ff78b38..495b3e05a9b1 100644 > > --- a/drivers/staging/media/ipu7/ipu7-boot.c > > +++ b/drivers/staging/media/ipu7/ipu7-boot.c > > @@ -263,6 +263,8 @@ int ipu7_boot_init_boot_config(struct ipu7_bus_device *adev, > > GFP_KERNEL, 0); > > if (!syscom->queue_mem) { > > dev_err(dev, "Failed to allocate queue memory.\n"); > > + ipu7_dma_free(adev, adev->boot_config_size, > > + adev->boot_config, adev->boot_config_dma_addr, 0); > > return -ENOMEM; > > Adding a free here leads to a double free. It's the same issue. > One magical cleanup function in the caller. > > I haven't looked at this but I bet there are bugs in the error handling > since magical cleanup functions are always buggy. Btw, if you had kept the "adev->boot_config = NULL;" assignment that you had in v1 then that would have prevented the double free since ipu7_boot_release_boot_config() tests for that... This information is not useful to you at this point but I'm sure you will find it frustrating. :P regards, dan carpenter