Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1862851rdb; Mon, 8 Jan 2024 12:47:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IF84Pcpcx2h77rqeobBxrlKW5qwqG2T9fRQ+yFcHkwrN9+RqF3y9+9ruIB9M4fHRKrLce6v X-Received: by 2002:a17:90b:34a:b0:28c:c6a0:f52a with SMTP id fh10-20020a17090b034a00b0028cc6a0f52amr1485022pjb.84.1704746851822; Mon, 08 Jan 2024 12:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704746851; cv=none; d=google.com; s=arc-20160816; b=UIbgb0MJjnzadOQQn1Q99oHQczzEXCsi+3DQu0uzkIHWT8033soBi3IOi1Cr9ikAAg YiTLjlTZ2vdSUjAAjHGRsGf8IwkhkJKEaDwq6+fcn2HDxP4G2TnQqI0nyD//+PL2Xc+B m2l02komGcRP2XBUIjeqQxrY5H25cDbiOHeIsTuVwEg3dyKj3a6dx1RNWh222xyRrIqY HBNdnwIIRdroyYyy6muUHpOPuNAg9qhSVQEUskZq0JQYtMGMxCYaMgjY4xT6vx2S47ys ZcJT0VCVbJKRk6NjbLYcNCMRCepDVi/XXk1tOo1CwQI6zhxrLgRWfxMOlr58Uda3xhhK GC2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=RXargCYC5tp6JJ5K6cG6yI4OFY52NWFfheJBVFalhQw=; fh=mp/qpDEzZTETBZAP4vyPTEFA195q9D7RBx3Xibd/MIg=; b=t/2Lv2LDAVbhbf+MsaE+mn7m4nPh/Ksmw6RxmuTMKE20K2btpSMliahY+PLq8WMYqV pgiLtOMw1M2s8ybzX6EAFubWeP/k6z9kb6AeRFrKfb6ijsMAdWqBiUgvxOJBWtkHIS3k Fiyh76vqoEnS81C8M/SOWqncGmDR8sorcOdH6uVE8f/aVzMyYufEOKuibXKp46bztCGc 6HHyzRlfshuX6HzUntYoQ7mebube64DmWqE1amgsnxCfGZu50S+p7P0BWTVP2Hf2yX+c 4VCKvLDLwnZS2iu9iQzYCdawjN/wUZOSFZJDg+JPH1MT6wJa2G36iEQNZYRuOv4mvFPc E9tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fu3FyYNg; spf=pass (google.com: domain of linux-kernel+bounces-20106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u8-20020a17090a4bc800b0028ce652392esi415884pjl.142.2024.01.08.12.47.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 12:47:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fu3FyYNg; spf=pass (google.com: domain of linux-kernel+bounces-20106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5E2E6B20B62 for ; Mon, 8 Jan 2024 20:47:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8DB852F97; Mon, 8 Jan 2024 20:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="fu3FyYNg" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3780654BDA; Mon, 8 Jan 2024 20:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704746837; bh=UQ/Pqq9hCugSxC3Fzh31NRAczf6loqtAEVkRzY9ZrUY=; h=From:To:Cc:Subject:Date:From; b=fu3FyYNgD+idTI4piSZ17tN+M/ZavzrqZBkRgO1z+9KFmMqXzHO/8MaMHHeKbgKmT FCunKCxfVFTFdoQar8AN/9ZqZr73MNkTPjR4aPHsgoeJMS3NuE0UjmZFmJZh9B/wfm uBEtKjRtItys+DDipV5HuIPi+QxZbVslRP6BrQ25fHTV6u4sqn6rq+CbWBPIPNKJIu Z7TIDqO1NBgHE+VnrVF1jYrZ+UsjsfAxgLF+mpZLRIqqcC8Nrg5QeSBRea5wf5wLY2 BeZvGKI5a1tuhoHWLF+B5uVf+5ch4VRy95pl7af70cunodjkUWc85q+yz1zoXVfAPQ RwNDbkGikAX2Q== Received: from localhost.localdomain (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 924B33781475; Mon, 8 Jan 2024 20:47:12 +0000 (UTC) From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Mark Brown Cc: AngeloGioacchino Del Regno , kernel@collabora.com, =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Jaroslav Kysela , Kuninori Morimoto , Liam Girdwood , Matthias Brugger , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado=20via=20Alsa-devel?= , Rob Herring , Takashi Iwai , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-sound@vger.kernel.org Subject: [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing Date: Mon, 8 Jan 2024 17:44:58 -0300 Message-ID: <20240108204508.691739-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()"), the dai_name field is only populated for dummy components after the card is registered. This causes a null pointer dereference in the mt8192-mt6359 sound card driver's probe function when searching for a dai_name among all the card's dai links. Verify that the dai_name is non-null before passing it to strcmp. While at it, also check that there's at least one codec. Reported-by: "kernelci.org bot" Closes: https://linux.kernelci.org/test/case/id/6582cd6d992645c680e13478/ Fixes: 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()") Signed-off-by: NĂ­colas F. R. A. Prado --- sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index 5bd6addd1450..bfcb2c486c39 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -1208,7 +1208,8 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) dai_link->ignore = 0; } - if (strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0) + if (dai_link->num_codecs && dai_link->codecs[0].dai_name && + strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0) dai_link->ops = &mt8192_rt1015_i2s_ops; if (!dai_link->platforms->name) -- 2.43.0