From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 B91DA386438 for ; Fri, 17 Apr 2026 08:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776412898; cv=none; b=MF40OpOyZCuWLYnLpFS+b4yEWVl+GAjjNXEEVJMH35d1J3SKFfAfUjtGTGjhZCzDbs5/NVMua30FxB2ToJYHd5cQMvkX2Q5T3y5B24Y4LRGSULFFSg4KvJJf43dtjXAWvWeoE2UanQpsE+0rVcCaOswlO0r3npQhttTrc9dBc1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776412898; c=relaxed/simple; bh=E61CLs/TOZ+fqQeNjE+IVq/6jI44xVi6r2MOe0iAMFc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IanzzOTdGsfu6ZhvhzW5sbKi5c37Cq2h0zll5NNc2Rp0ov1LCzE9DOf9SynDxfZyxvah6yO6WajoVj/Ok/NgHUwKNPtGgmI5+6XzpxN2TWhQwBFnbDyNYunWX2RtJFnan8XULQ1z9l4G45eyftRIwAboqmQy+S012iQZKReCNjY= 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=CGy5iI1B; arc=none smtp.client-ip=209.85.221.52 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="CGy5iI1B" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43d77f60944so264826f8f.3 for ; Fri, 17 Apr 2026 01:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776412894; x=1777017694; 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=WAbA/rea0AphHw4Y3No18IGU2RBEKq1oJbRMenVLx2g=; b=CGy5iI1BaWvvwidWJF8LQhzvGsKiLFtR1iiCNRu+yjDeS1eWQui7pYG3KiiJV8vSIB 4s/EVvWoFY963V0Dm216eFqPg0Af8t7UG1EvtviuQ9pQhQvNUBFvYgJovca/BYgwmaoQ oEOVlXkpwWO4CR1vfyrYwQlDTaoPdjujcWfQU8YRDhVAhPX7onpa/tIKjW6cWhQ4wQyc ZvQp71+DuOf8V5eWHCwjEQD0A3P5Oj6SP8f69Tlp9MqPrGqNgy9GELGLzMmiziiwyj04 XCW9SExsyW0haj36MfNPr0FYq2CvCqYHMlFTMBIREgltt3PuQPp8oX95FVtTo3JpfiAb NlIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776412894; x=1777017694; 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=WAbA/rea0AphHw4Y3No18IGU2RBEKq1oJbRMenVLx2g=; b=hP+L14UZUWwpLXurqyHTWuL+cmnSJYBFVq8n7Lh3WZS9mlGUGdfwtfN1zjx0DF8BgG hZ7WEhG3T9cf+pywnpbwnGeRsrZSxiwC6DhMgHfBaZLj3sr7knyClVcbsPNGBP6f4xA1 cvz0VJ+N1B0J+qP9dEKH/EwS8SymCyXNht6bECHpOh4BklOoGZz/1YYjIwhx2qBrI9pX 3pu/FSn1dyGEdzx+zPlpe1ih3CZWi5ChuAjmzXY1C7RUB9Z63GooyvT0fkdDBSFTF12o eMMvZAq+mqOhYRrVRrHiJNcaYlFylE8kRqCn0bQrdVN6ssoLKx0jTfCwvoUdVtgJHjAy 84zg== X-Forwarded-Encrypted: i=1; AFNElJ/utECoKRPB9zjpGUDpcxuJrsTIz13GHQoxuGaSQjT26+P/rcBoPXEDbmxtevKC/BfjXSlddq9rISFCb9w=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1CIloze8PQSgCStH4LfaXc/qNs8Mhe0DxeskBAUCnmD1fqWpH sM4+HCqeUemZGFYnT/1RHoFtCzVC9lIj7bxYxiEAhZMsc/71i9la2f1I X-Gm-Gg: AeBDievESanchZiO3pzmEyR7ArOslldsl6AuSKfhCCO0WpZ+hVZgDYNcsFnI80PhRwY 9T7zY79JzIBHueWX7ZM/mP1HQcH37WxQGVbHxflAIRjHYiYAUTepPR06pN9V+ZL4gTol6n4r9P6 tAncEODc3/YMGbIzstSMl+JjFMRQohg7FgG/Gfxk9WxflkjSzxd7qkZsezqEalyd9vukEl2idvg nMWoQZoJ42/5xGojp+hyACC2i2v4ttroEJJeTrI9dlQxQDLJEWl0w69dTM3NE/Ekt0FUPQWZfeT 13+UEco6BGB6yP4ui+zj43kUGDhdcPAMBBofrLjj0QPQXKdZli61hg3dqfZlpZ66exY3qEVTeIh LEMIInic3w43rnkLHofElHgKf/ROkYkwmM0EBF1EBdLYIOg0u5ltEYWSyYEM5UQ5lV75CzaywVV HiD+03G7JrFtcNmrpHs8VbP3JVtosMehSc6CE/Vk0M X-Received: by 2002:a05:6000:601:b0:43d:b0f:eb44 with SMTP id ffacd0b85a97d-43fe3dd4e9fmr2452398f8f.15.1776412894006; Fri, 17 Apr 2026 01:01:34 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e4633bsm2468491f8f.26.2026.04.17.01.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 01:01:32 -0700 (PDT) Date: Fri, 17 Apr 2026 11:01:29 +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: <20260417073939.2686170-1-hhhuang@smu.edu.sg> 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. regards, dan carpenter