From patchwork Thu Aug 10 15:56:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vasilyev X-Patchwork-Id: 9897495 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 5BF33603B4 for ; Sat, 12 Aug 2017 21:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF5E2889F for ; Sat, 12 Aug 2017 21:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43D9B2896D; Sat, 12 Aug 2017 21:42:25 +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 77A042889F for ; Sat, 12 Aug 2017 21:42:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6CA9726722D; Sat, 12 Aug 2017 23:39:47 +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 4BAB92675C6; Thu, 10 Aug 2017 17:56:49 +0200 (CEST) Received: from smtp.ispras.ru (bran.ispras.ru [83.149.199.196]) by alsa0.perex.cz (Postfix) with ESMTP id 73AE62675AD for ; Thu, 10 Aug 2017 17:56:46 +0200 (CEST) Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id 766525FB87; Thu, 10 Aug 2017 18:56:45 +0300 (MSK) From: Anton Vasilyev To: Krzysztof Kozlowski Date: Thu, 10 Aug 2017 18:56:39 +0300 Message-Id: <1502380599-13535-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 , Mark Brown , Sylwester Nawrocki , Anton Vasilyev Subject: [alsa-devel] [PATCH] 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() permorms 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 --- sound/soc/samsung/i2s.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index af3ba4d..6beeea8 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1382,7 +1382,8 @@ static int samsung_i2s_remove(struct platform_device *pdev) sec_dai = pri_dai->sec_dai; pri_dai->sec_dai = NULL; - sec_dai->pri_dai = NULL; + if (sec_dai) + sec_dai->pri_dai = NULL; pm_runtime_get_sync(&pdev->dev); pm_runtime_disable(&pdev->dev);