Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145011pxv; Fri, 9 Jul 2021 19:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymeU+hHIJDHCZ48LUYGeqa0tmKtQA6G+MyozddFXfeQ9KDZRPVOeSjrANms0mq9KSRoAwD X-Received: by 2002:a17:907:96a4:: with SMTP id hd36mr26851091ejc.251.1625883992901; Fri, 09 Jul 2021 19:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883992; cv=none; d=google.com; s=arc-20160816; b=qYuJenTLYp6SOjyHP3ALdtyrhB++dfapCa/imyZ6lFQigHq9GY40GNy5N00WtAuPLI MgWupxo/EBig7xQKQi8CW3FmsiBa3ospInc6+1zUZctsxb1tbbmwVZYHZIP6TAUJJXwq 6nRLsVCYZYjDqqEhpUHVbh9AwYmiEPQhmqCyzQzi4njNUx8DsRVWiUMii6LDTEltIujx yPHGDTDbUYhYGislTFru9e0/mNmRzyNky/OE/iWD3v3Xh3GcIOqLk909Luvt+EG9Ppbs 3h22oMXodeZfDp+T56LYVRuXVDvlxkjJBa0apqDamzvGSv3b0u9j1KUdJAWbUEuImAYK 4xzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UaABdGu60dRV4Pzed/pdXM00gBSkiyN5T184T/Mz1X4=; b=nh2R1GTvf7iuqg7jwch+PuH9pYyFABgaNV3fa/r31k7Brq91CvjZvmCvT8YvQq1YcO ocm263gWMEIaYkbU0B4zjHu3KlcUdQkBP/1OxyayfvqDFB79dEVfc+4Y2/H8moRihVOC rcRZgFdHmimmvKUsusGejoxUch2Ai3R9ud8bsiNBJgrlLPmj6KIEIYNAnnwqWmZqLnE/ kXUXhhVi0mI5vIlhaG/W+73H8Fe/pGvUpg+tLk6alcAaZD+KYqczc8NvhuWrwvIsOFBd /ZSJ1xZoSKp5uaAS9D2dL3zhV8n8o1lJx8csBddtXpdBXD/W4kBL83YfnguyVr2qlxj0 rFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tfUsU5cO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ko14si2299330ejc.179.2021.07.09.19.26.09; Fri, 09 Jul 2021 19:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tfUsU5cO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233778AbhGJC1O (ORCPT + 99 others); Fri, 9 Jul 2021 22:27:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:42628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbhGJCZ6 (ORCPT ); Fri, 9 Jul 2021 22:25:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 77331613DF; Sat, 10 Jul 2021 02:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883793; bh=WTR3HR2O77FCPjnMuu4vUPAkOF6KxIhKe3sBHTkkkNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfUsU5cOjIKmqm9gNSqNKrnUACi6wzy/9uPEWtBZnWJXcCeU9KsrSqPMMjyY4tfqf pfHipOO2msq0GV17kP63JM8igqEA39Pu8C6dpVhIIPBJz+3JGNlDI4NFXd6nDi/Uhg +UC0iTlWbfYb9Ep7mFQjLJ8j9+kIq7ZKIC0dAuVxJx34eKTpCVJe92edeHlZkYUZJw RLYGGUjuSrceD23ta52aP7BnZC1CE+ZJ9zowTSm55qBd2OEdYIcOk8HNdZv1P0Awqe PM1SpS+Sv+IWsP1ayb06FR5iaWRZT7zYTIH5Qh1eUwBIpW6Szf1a45vHFUulc/o3vr O9t7lPXlZ/3sg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin , alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.12 058/104] ALSA: sb: Fix potential double-free of CSP mixer elements Date: Fri, 9 Jul 2021 22:21:10 -0400 Message-Id: <20210710022156.3168825-58-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit c305366a37441c2ac90b08711cb6f032b43672f2 ] snd_sb_qsound_destroy() contains the calls of removing the previously created mixer controls, but it doesn't clear the pointers. As snd_sb_qsound_destroy() itself may be repeatedly called via ioctl, this could lead to double-free potentially. Fix it by clearing the struct fields properly afterwards. Link: https://lore.kernel.org/r/20210608140540.17885-4-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/isa/sb/sb16_csp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 4789345a8fdd..c98ccd421a2e 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -1072,10 +1072,14 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p) card = p->chip->card; down_write(&card->controls_rwsem); - if (p->qsound_switch) + if (p->qsound_switch) { snd_ctl_remove(card, p->qsound_switch); - if (p->qsound_space) + p->qsound_switch = NULL; + } + if (p->qsound_space) { snd_ctl_remove(card, p->qsound_space); + p->qsound_space = NULL; + } up_write(&card->controls_rwsem); /* cancel pending transfer of QSound parameters */ -- 2.30.2