Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DF22C43461 for ; Thu, 3 Sep 2020 04:49:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18F1720758 for ; Thu, 3 Sep 2020 04:49:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="tPTzDGzK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="k56V4zjO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18F1720758 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7CD421693; Thu, 3 Sep 2020 06:48:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7CD421693 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1599108579; bh=xUN/KEIOO4iwgVPaPQrHDkQ9DyzJ78QljMI623UURTY=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tPTzDGzKYhUpvEGQVz5XHdDzLPXETNaiwfiemm+C3hnmRb2mFNc9pDMfVezY61ANX XusiXyYbVBWj0K2KM958xvcm2YceyApPVOg38X9Yr4+FG7p4AiJQbt8wzojphfl/Qc ppzwm4hegRPJmBeUGhbW5iQGW2xrV61xG98qPtzw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3C5EAF8025F; Thu, 3 Sep 2020 06:48:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B512F80278; Thu, 3 Sep 2020 06:48:02 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3346AF8021D for ; Thu, 3 Sep 2020 06:47:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3346AF8021D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="k56V4zjO" Received: from localhost (unknown [122.171.179.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9E4420758; Thu, 3 Sep 2020 04:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599108474; bh=xUN/KEIOO4iwgVPaPQrHDkQ9DyzJ78QljMI623UURTY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k56V4zjOU2jV2CXTkdtp+1YrI/IuAbDxN9M5fkVV2ub04/O79eOGt0hoXzku5rCeB uqDeqDTsxmC5eHy3lzwkBfaiCWQg0Bb7ps6vwauMnMWn3mF18SN5W4IRXgbS0VzKKI 8HmyWjZbd+5uwU1z1hiqTmdvTPq7syhHU/vCD6Ig= Date: Thu, 3 Sep 2020 10:17:50 +0530 From: Vinod Koul To: Pierre-Louis Bossart Subject: Re: [PATCH 06/18] ALSA: compress_offload: dereference after checking for NULL pointer Message-ID: <20200903044750.GD2639@vkoul-mobl> References: <20200902212133.30964-1-pierre-louis.bossart@linux.intel.com> <20200902212133.30964-7-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902212133.30964-7-pierre-louis.bossart@linux.intel.com> Cc: tiwai@suse.de, alsa-devel@alsa-project.org, broonie@kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On 02-09-20, 16:21, Pierre-Louis Bossart wrote: > Fix cppcheck warning and only dereference once the initial checks are > done: > > sound/core/compress_offload.c:516:38: warning: Either the condition > '!stream' is redundant or there is possible null pointer dereference: > stream. [nullPointerRedundantCheck] > struct snd_compr_runtime *runtime = stream->runtime; > ^ > sound/core/compress_offload.c:518:17: note: Assuming that condition > '!stream' is not redundant > if (snd_BUG_ON(!(stream) || !(stream)->runtime)) > ^ > sound/core/compress_offload.c:516:38: note: Null pointer dereference > struct snd_compr_runtime *runtime = stream->runtime; > ^ Acked-By: Vinod Koul > > Signed-off-by: Pierre-Louis Bossart > --- > sound/core/compress_offload.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index 0e53f6f31916..e3eb314acb10 100644 > --- a/sound/core/compress_offload.c > +++ b/sound/core/compress_offload.c > @@ -513,10 +513,11 @@ EXPORT_SYMBOL(snd_compr_malloc_pages); > > int snd_compr_free_pages(struct snd_compr_stream *stream) > { > - struct snd_compr_runtime *runtime = stream->runtime; > + struct snd_compr_runtime *runtime; > > if (snd_BUG_ON(!(stream) || !(stream)->runtime)) > return -EINVAL; > + runtime = stream->runtime; > if (runtime->dma_area == NULL) > return 0; > if (runtime->dma_buffer_p != &stream->dma_buffer) { > -- > 2.25.1 -- ~Vinod