Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3460463ybg; Fri, 25 Oct 2019 04:34:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfXj1VICcLaXPZKqLM6ldUgV03Hi9AMZBI1En8U9+DRcJpL7ruoI1eZw/hQu4g4BU+/rcI X-Received: by 2002:a17:906:7094:: with SMTP id b20mr3010179ejk.134.1572003290410; Fri, 25 Oct 2019 04:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572003290; cv=none; d=google.com; s=arc-20160816; b=LN7N4E1AfZqj0RULVA/M2lskimXeIJNrwdmufwzVKVAWOtcZsJSbIIZgNFtAdksO1s tQWdhL7hXDV8C/LhHLZ/XGtcnpgDtEbAyrdcHYYsN9VepQ9qlxdubxhcvY/TvlDXjqAf zEVwUeXfmei0ShGibmlI2kDuwgI3xxPI7U2hDAI/iEQjgM2W7tyWNMIbpyxB7S+9FV99 rq4YeywE+8futyJEWsa8dQFVPooMhhDHV2fLj8z8IUzPrr/J5yXV0nyQ35+QS456TWxc qv8rFYGahJCC0GDgxv8KwSPrzYcrO7h+z8q93tIFfU9IYPZWhpBjDnC5vrz3W4xr8c8z j4qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cpGuyfLGGViRLKR0NnNPjBua4toUnOzYD0t2qNUSDg0=; b=P40nAlbKZTvXhg2HfIiU9D3JkBHUKL4rOP6IUlBsuxFmIGQfXiJgxTaIdiu0qaFe+3 JU5Nad7jZUqXL+rfZben7MVCDyfqwSfmYa2olu26+erq3sE0+7BnBNKySwI2ui/w+/pv v4EBbE4Ho7JRntvqxl0KSimyqYUXl5vC1Hy63csBz7LvtgL7tbHpMyXJrxWpCzx/g768 1vCELe133vQcaikeW26b5Pd9INPbMcO9aws3Cg2IBWdBFXAq7k97FUeA3c6xCJGz1p/t JX8EVJ/IJyKE5ov1YenKvTjwh1APdG8XAKoqzkVwp0qVkl7h0JB/YLUZD3ZmS3ZpUMzp DQrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y40si1026227edd.383.2019.10.25.04.34.25; Fri, 25 Oct 2019 04:34:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502067AbfJXMqX (ORCPT + 99 others); Thu, 24 Oct 2019 08:46:23 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37367 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2501989AbfJXMqW (ORCPT ); Thu, 24 Oct 2019 08:46:22 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iNcVG-00080W-U9; Thu, 24 Oct 2019 12:46:11 +0000 From: Colin King To: Bard Liao , Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Curtis Malainey , Ben Zhang , alsa-devel@alsa-project.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] ASoC: rt5677: Add missing null check for failed allocation of rt5677_dsp Date: Thu, 24 Oct 2019 13:46:10 +0100 Message-Id: <20191024124610.18182-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The allocation of rt5677_dsp can potentially fail and return null, so add a null check and return -ENOMEM on a memory allocation failure. Addresses-Coverity: ("Dereference null return") Fixes: a0e0d135427c ("ASoC: rt5677: Add a PCM device for streaming hotword via SPI") Signed-off-by: Colin Ian King --- sound/soc/codecs/rt5677-spi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c index 36c02d200cfc..3a17643fcd9f 100644 --- a/sound/soc/codecs/rt5677-spi.c +++ b/sound/soc/codecs/rt5677-spi.c @@ -376,6 +376,8 @@ static int rt5677_spi_pcm_probe(struct snd_soc_component *component) rt5677_dsp = devm_kzalloc(component->dev, sizeof(*rt5677_dsp), GFP_KERNEL); + if (!rt5677_dsp) + return -ENOMEM; rt5677_dsp->dev = &g_spi->dev; mutex_init(&rt5677_dsp->dma_lock); INIT_DELAYED_WORK(&rt5677_dsp->copy_work, rt5677_spi_copy_work); -- 2.20.1