From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 E61CCC43381 for ; Fri, 15 Feb 2019 02:42:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EBB221A80 for ; Fri, 15 Feb 2019 02:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550198526; bh=Pc2MhCz8X5hRrfdPLDpD1H6sISHv2F+Cdb+0qUwFsgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=a6dMJF0YFR9OqJ2Nq7fm8kyNphBq8YcEtpW9yFruFE15ee8b5a7ToTszWnVemLWGS isKKuM/yShE/KyGeA4xYdiJPt6jTVmgeHbRFLoB5BZtSl7nzhrpjSIuNXvetaKWvOo ai+yDXEDrexKZ6u/nvLdaA3+oIfDVPupTOMSxLvA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbfBOCl7 (ORCPT ); Thu, 14 Feb 2019 21:41:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:49650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731685AbfBOCJ3 (ORCPT ); Thu, 14 Feb 2019 21:09:29 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3FE3222C9; Fri, 15 Feb 2019 02:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196569; bh=Pc2MhCz8X5hRrfdPLDpD1H6sISHv2F+Cdb+0qUwFsgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=18oTHget0bgLIJqwyDtyO83Mtvu4JNylcB8h3H5vPghZkHOVUlRubxrrpShbdphAQ aKBqflsOaeJXtDk9ogbL5JW4CfmejHMuZSYjn/3nZ8s7jtaevW4OKIhkKhxWj3+CcN JWWKpuNd0J/m9doMNx2uewEj5/qBI05KiLMX10SA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.20 17/77] ASoC: core: Make snd_soc_find_component() more robust Date: Thu, 14 Feb 2019 21:07:55 -0500 Message-Id: <20190215020855.176727-17-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Brown [ Upstream commit 5a7b2aabc1aa0393f067d9325ada96fdf67f8cb7 ] There are some use cases where you're checking for a lot of things on a card and it makes sense that you might end up trying to call snd_soc_find_component() without either a name or an of_node. Currently in that case we try to dereference the name and crash but it's more useful to allow the caller to just treat that as a case where we don't find anything, that error handling will already exist. Inspired by a patch from Ajit Pandey fixing some callers. Fixes: 8780cf1142a5 ("ASoC: soc-core: defer card probe until all component is added to list") Reported-by: Pierre-Louis Bossart Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 17632da21ba7..e4da6656f65f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -742,7 +742,7 @@ static struct snd_soc_component *soc_find_component( if (of_node) { if (component->dev->of_node == of_node) return component; - } else if (strcmp(component->name, name) == 0) { + } else if (name && strcmp(component->name, name) == 0) { return component; } } -- 2.19.1