From patchwork Fri Aug 11 13:06:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vasilyev X-Patchwork-Id: 9897505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3994B603B4 for ; Sat, 12 Aug 2017 21:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C8D32889F for ; Sat, 12 Aug 2017 21:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217112896D; Sat, 12 Aug 2017 21:43:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8838B2889F for ; Sat, 12 Aug 2017 21:43:47 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 279CC26727C; Sat, 12 Aug 2017 23:39:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D740026762D; Fri, 11 Aug 2017 15:06:47 +0200 (CEST) Received: from smtp.ispras.ru (bran.ispras.ru [83.149.199.196]) by alsa0.perex.cz (Postfix) with ESMTP id 047B92675CA for ; Fri, 11 Aug 2017 15:06:45 +0200 (CEST) Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id 014955FB23; Fri, 11 Aug 2017 16:06:45 +0300 (MSK) From: Anton Vasilyev To: Sylwester Nawrocki Date: Fri, 11 Aug 2017 16:06:23 +0300 Message-Id: <1502456783-2047-1-git-send-email-vasilyev@ispras.ru> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Sat, 12 Aug 2017 23:39:37 +0200 Cc: ldv-project@linuxtesting.org, alsa-devel@alsa-project.org, Sangbeom Kim , linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Krzysztof Kozlowski , Mark Brown , Anton Vasilyev Subject: [alsa-devel] [PATCH v3] ASoC: samsung: i2s: Null pointer dereference on samsung_i2s_remove X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP If (quirks & QUIRK_SEC_DAI == 0) then samsung_i2s_probe() doesn't allocate sec_dai and pri_dai->sec_dai remains Null, but samsung_i2s_remove() performs pri_dai->sec_dai dereference in any case. The patch adds sec_dai check on Null before derefence at samsung_i2s_remove(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- v2: Drop initialization of sec_dai by NULL at samsung_i2s_remove as Sylwester Nawrocki suggest. --- v3: Fix typo in the comment --- sound/soc/samsung/i2s.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index af3ba4d..6f896e3 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1376,13 +1376,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) static int samsung_i2s_remove(struct platform_device *pdev) { - struct i2s_dai *pri_dai, *sec_dai; + struct i2s_dai *pri_dai; pri_dai = dev_get_drvdata(&pdev->dev); - sec_dai = pri_dai->sec_dai; - - pri_dai->sec_dai = NULL; - sec_dai->pri_dai = NULL; pm_runtime_get_sync(&pdev->dev); pm_runtime_disable(&pdev->dev);