Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144286pxv; Fri, 9 Jul 2021 19:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiczX9KbiRMHNLtKo3acOsYvkatFrufE9q/mXuAXnwIxKCAH+NRCQQwS1WSRhKmmn3ew65 X-Received: by 2002:a05:6402:10cc:: with SMTP id p12mr51392144edu.328.1625883891037; Fri, 09 Jul 2021 19:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883891; cv=none; d=google.com; s=arc-20160816; b=VIFfy6pqdOczl+DSOvInkDf3yAjy3WnObQ6LCwijRoGSmMOc4qexrgJpdCGlZYj7fy zlLxvMShcwidevynkp9CBc7XQxN7LZws6YjcwwXxyAR4s53On6nEJnZJuYd+7pM9Ui9U qbUuZwXjf+5373zJCw5TkVmoS+wZc71gA+IhWlIySuPqloEbrJ4EKvpl76Xm9oLOj+sq iudayGA1YXx900te3CKWGRKVa6Abvh0zDttbRa76urX1ddV9jGoZhNgCEtQscs9Oy7r7 OqO/l9GzdP/zswVNUxew6ojFv6LekYCIDhywbKwOydoopD5+E6Qpx/M3PoR2GE4nFTxi moZw== 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=c+XanVJpq0eqtqyg1CUvuy0CiO9zBTgsFxsBtWsgKxBMMLPLGIMsrL7I1NaJU0IDFf qcIugAgvaZaOfohGic5TSsdD3A5jDJ9BVdL2wubPma18h1aavhVa0Kkch0+3fUOAvFKO XT63SsSAifbZacQwZvASua9YT72ajxx0iBRgNmT28GjbAitjbG3SU9RX8XYYx3mGrj34 nzrjw53cBjRGtoEaJGAMCKx+CFQ9Kd+kax8bg9tdZAMoqHsIu5ZS+FrrBWYhZHBCI2a2 nEroUfTZ2/x+pI322/ZTjIw13sIVAiQ1dy+JnLZVDRZNgkEb9XOoHe6qfg2KwCPjydNr eUMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZQSXgYo3; 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 c12si11000792edx.372.2021.07.09.19.24.28; Fri, 09 Jul 2021 19:24:51 -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=ZQSXgYo3; 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 S232235AbhGJCXK (ORCPT + 99 others); Fri, 9 Jul 2021 22:23:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:38416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232761AbhGJCWF (ORCPT ); Fri, 9 Jul 2021 22:22:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF84D613FE; Sat, 10 Jul 2021 02:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883554; bh=WTR3HR2O77FCPjnMuu4vUPAkOF6KxIhKe3sBHTkkkNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQSXgYo3mPFvsfNIYuNDm/IKSA+aCHi/rILlM2m/RqrtW41Tkpu2EVeeJy9CMrcqZ QIfin3BDVCXWdoqZLeijNNbfwznbLQPC5TL/gRIzwD1UwLdtYrZYBoerGNzv0u+3LS 1aOy3iiRiSwobz3vmVvaV/I2MaCv1ZAIUMyfuR9ZZEX4uIGirsPDnM45sTLFIOLiNs gV6GdzR1d5CIA8qH0zieNViiTAeIaFeb/dJ1rbd1V+mtKnGWy6gAFBpt84tU1JDgzs cz1JcRt1jA87XgeYxsv2pw+vmvkpgWAWxpkK50YT87F98LRlGlhc0jnuWjQCIIZdfW off+Z4uXMgL1Q== 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.13 063/114] ALSA: sb: Fix potential double-free of CSP mixer elements Date: Fri, 9 Jul 2021 22:16:57 -0400 Message-Id: <20210710021748.3167666-63-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710021748.3167666-1-sashal@kernel.org> References: <20210710021748.3167666-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