Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp947395ybt; Wed, 24 Jun 2020 15:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlfG+tYwpNsNyFIE/sV+z47uROFbKrwqbTsJdIpB2kDxPiHDXHY4mZufIaXS9fgPctk4Ud X-Received: by 2002:aa7:d6c1:: with SMTP id x1mr28266059edr.154.1593038163596; Wed, 24 Jun 2020 15:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593038163; cv=none; d=google.com; s=arc-20160816; b=dh50ZjbTXVyM2aMksXRyIX6cBViXe5vNLeU88TScW9ertX7dn8m3GQmKS0L0u8cnaR 6sI/RjJe0YfRaSk/QnF35qmcTSF5JehXwkYUfRnUlq7c3x8MZfbn/qGyaorH+zHTrVAL FyHbXjDzrRVT+A8UGIlDXqcXaYSdrkDbju2zqEx+Pd4JIqXIwRvoxMhSMOY1z2TiwG/g ThVeWfiwNCzHL1N8WpiRSqaeEFnWBTHPeuu615uF+PXl1bK+CQ24w3EX2Pfi7okJMzGe 8FU1gbjR2h9eUU/W5Pso0pjYkoX9P9QDqW2udl/Wo4EhhgOMyovyEshmvmt4uf3wG74f Mukg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ejfiAqS/QpI6UZH36OdAjr53Ch+HUJR3UbEAdiZoxWw=; b=uKUBN70cIT2TNYD26PWKS2y5Pb/G94lP4zgo7smXwqtDVkTWhAthtMPu0Q2yMFH0MB roZwMfnRdCf54eML9H7Nf4tdCpXh958/R4EUPXfgAltLG/NhJCZEY3IP55rAe//A4cPn KOzEhIfiAepff2CmR62haEtQ9HY6sX+MzghVSfXVWAD4AFDrDa9a7vriRbOzIl2U7LWB JtAyNZauIIKPhIcpNcVWel3yB6eKGvcZtbD/uCPR15N9XMZC1o7eDbhSDpCqUgQ/2t/J mDkUkwnHfCUK7EM7lqdnPjSeun9cNfDZ2yAzCzTmWO3H+y0exFi6zc2xM5kOyz/Al8rr AJYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs2si4135304ejb.140.2020.06.24.15.35.23; Wed, 24 Jun 2020 15:36:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389522AbgFXWfK (ORCPT + 99 others); Wed, 24 Jun 2020 18:35:10 -0400 Received: from s2.neomailbox.net ([5.148.176.60]:34813 "EHLO s2.neomailbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732806AbgFXWfK (ORCPT ); Wed, 24 Jun 2020 18:35:10 -0400 X-Greylist: delayed 1298 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Jun 2020 18:35:10 EDT From: Antonio Quartulli To: "Luis R . Rodriguez" Cc: linux-wireless@vger.kernel.org, Antonio Quartulli , Kelvin Chui Subject: [PATCH] crda: don't memset ctx before releasing members Date: Thu, 25 Jun 2020 00:12:21 +0200 Message-Id: <20200624221221.16419-1-a@unstable.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 Signed-off-by: Antonio Quartulli --- 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