linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crda: don't memset ctx before releasing members
@ 2020-06-24 22:12 Antonio Quartulli
  2020-09-25  7:54 ` Antonio Quartulli
  0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2020-06-24 22:12 UTC (permalink / raw)
  To: Luis R . Rodriguez; +Cc: linux-wireless, Antonio Quartulli, Kelvin Chui

reglib_free_regdb_ctx() is currently memsetting the passed context to
all 0s and then attempts to unmap/release its members.

Obviouly this can't work, because after the memset() all ctx's members
will not be useful anymore. Attempting to release them may actually lead
to crashes. Even if no crash should happen, this operation will still
result in memleaks.

Fix this issue by removing the memset() at all, thus leaving the members
intact so that they can be properly released.

Signed-off-by: Kelvin Chui <kelvin.chui@kaiwoo.ai>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 reglib.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/reglib.c b/reglib.c
index 4dee401..9a56a6d 100644
--- a/reglib.c
+++ b/reglib.c
@@ -287,7 +287,6 @@ void reglib_free_regdb_ctx(const struct reglib_regdb_ctx *regdb_ctx)
 
 	ctx = (struct reglib_regdb_ctx *) regdb_ctx;
 
-	memset(ctx, 0, sizeof(struct reglib_regdb_ctx));
 	close(ctx->fd);
 	munmap(ctx->db, ctx->real_dblen);
 	free(ctx);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crda: don't memset ctx before releasing members
  2020-06-24 22:12 [PATCH] crda: don't memset ctx before releasing members Antonio Quartulli
@ 2020-09-25  7:54 ` Antonio Quartulli
  0 siblings, 0 replies; 2+ messages in thread
From: Antonio Quartulli @ 2020-09-25  7:54 UTC (permalink / raw)
  To: Luis R . Rodriguez; +Cc: linux-wireless, Kelvin Chui

Hi guys,

On 25/06/2020 00:12, Antonio Quartulli wrote:
> reglib_free_regdb_ctx() is currently memsetting the passed context to
> all 0s and then attempts to unmap/release its members.
> 
> Obviouly this can't work, because after the memset() all ctx's members
> will not be useful anymore. Attempting to release them may actually lead
> to crashes. Even if no crash should happen, this operation will still
> result in memleaks.
> 
> Fix this issue by removing the memset() at all, thus leaving the members
> intact so that they can be properly released.
> 
> Signed-off-by: Kelvin Chui <kelvin.chui@kaiwoo.ai>
> Signed-off-by: Antonio Quartulli <a@unstable.cc>


Just checking if this patch is still of interest and if there is
something I could do to get it merged?

Best Regards,


-- 
Antonio Quartulli

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-25  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 22:12 [PATCH] crda: don't memset ctx before releasing members Antonio Quartulli
2020-09-25  7:54 ` Antonio Quartulli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).