Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp208671imj; Thu, 14 Feb 2019 18:44:21 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib7vvhXtBSzngWuURuD2bYoDisyYlP5V791aIyKhgzVGSsuedYtJKPhqDiX8u9fQTGbi99g X-Received: by 2002:a63:9348:: with SMTP id w8mr3117872pgm.198.1550198661896; Thu, 14 Feb 2019 18:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198661; cv=none; d=google.com; s=arc-20160816; b=JssNqxjpaXx5eu9/Us4dnMxyLnZJPf8qO/+v9D1Z4vB0W7OztJSAwxUTk5ipWafnjv QI+5yZJjUyrcrQ42VsdZFDVDYAwSadXFJoxko4/ev5Yq5W/p4K1Pr9n5ZUDClSKvgjhJ DRHPBArMs52SGJpWgNmJhzNCHI2du0K3wqn+jv+TyHHcWi0lcTdITCCB17u9+RWYHSFa dJDiozF6RuU+I/wWjG1ziz9RkQp21LBuFfWhePRUy2xoaxf6sbKBvclDAUyEsWR63xLD GI2M/ygfv3ynP/5xe4ivmuIljJ+l9RS9+Yx08bNie6RxWlaM/Uz1s4JBZfs71NYTqiW8 UOqw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A4ueltSw2IdlQG/rv3w0c/LhvS2g0HNx6/P1C0peVT8=; b=HcWog/fOwsplc0L0rIdHncXlBV70H5zr0m5bDVWKRSetaevKYoSVkyElGaQ41dkcvK 4hX+it29uP8timXzQ7rQj9OTrG/ocl6JTZUnF8e11/qaFY+O5ufq8los3PZv8S+qwXib AouvYxxXBYpRuFPET42o4Y4BYwTcYe3WsWs8rhIAkvNBbBDJ59GlqxQRA+meVEltK0eq xnA7Mq/3UO96GFty3XkbxIvlyf522Bmdm7geZd2s+RcMa04KYz/1ng8+B2/1LnWreCaq cz5bcUZoE99z/fP72l1bdTDTFHKz5I41oxrLua0O5D9yPr0Ve7W5e1eEpbDkykVlJ3Wa Z4rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=18oTHget; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b98si4444681plb.230.2019.02.14.18.44.06; Thu, 14 Feb 2019 18:44:21 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=18oTHget; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729775AbfBOCl7 (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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