lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241130103704.7129538f@kernel.org>
Date: Sat, 30 Nov 2024 10:37:04 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Yury Norov <yury.norov@...il.com>
Cc: Michael Kelley <mhklinux@...look.com>, Maxim Levitsky
 <mlevitsk@...hat.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>, Shradha
 Gupta <shradhagupta@...ux.microsoft.com>, Wei Liu <wei.liu@...nel.org>,
 Haiyang Zhang <haiyangz@...rosoft.com>, Konstantin Taranov
 <kotaranov@...rosoft.com>, "K. Y. Srinivasan" <kys@...rosoft.com>, Eric
 Dumazet <edumazet@...gle.com>, "linux-hyperv@...r.kernel.org"
 <linux-hyperv@...r.kernel.org>, Long Li <longli@...rosoft.com>, "David S.
 Miller" <davem@...emloft.net>, Leon Romanovsky <leon@...nel.org>,
 "netdev@...r.kernel.org" <netdev@...r.kernel.org>, Paolo Abeni
 <pabeni@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>, Souradeep
 Chakrabarti <schakrabarti@...ux.microsoft.com>, Dexuan Cui
 <decui@...rosoft.com>, "linux-kernel@...r.kernel.org"
 <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: mana: Fix memory leak in mana_gd_setup_irqs

On Thu, 28 Nov 2024 18:13:25 -0800 Yury Norov wrote:
> > FWIW, there's a related error path leak. If the kcalloc() to populate
> > gc->irq_contexts fails, the irqs array is not freed. Probably could
> > extend this patch to fix that leak as well.
> > 
> > Michael  
> 
> That's why we've got a __free() macro in include/linux/cleanup.h

Quoting documentation:

  Using device-managed and cleanup.h constructs
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  Netdev remains skeptical about promises of all "auto-cleanup" APIs,
  including even ``devm_`` helpers, historically. They are not the preferred
  style of implementation, merely an acceptable one.
  
  Use of ``guard()`` is discouraged within any function longer than 20 lines,
  ``scoped_guard()`` is considered more readable. Using normal lock/unlock is
  still (weakly) preferred.
  
  Low level cleanup constructs (such as ``__free()``) can be used when building
  APIs and helpers, especially scoped iterators. However, direct use of
  ``__free()`` within networking core and drivers is discouraged.
  Similar guidance applies to declaring variables mid-function.
  
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ