Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1599002pxb; Tue, 8 Feb 2022 23:38:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0c+/Ir32Q4npRONgTNx2FqcI8gI48WU32tJDTFOVQS+7g76do7CevbIdU39JKAIxUjAOV X-Received: by 2002:a17:902:f549:: with SMTP id h9mr1189821plf.62.1644392327184; Tue, 08 Feb 2022 23:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644392327; cv=none; d=google.com; s=arc-20160816; b=Y2TYcFNyzgh5dbbVjiOEDjV7Zh6dMchjBipVrZlBnKBoEE/RQYV6Q4V0J3VOFS9eoa tRul2GUtpwO+azO2uD4TP68Ryomf7Ghp1UuYRa3DB4+ZdAVf/dglicw9y8iLrnOE6PfA 2d5RN07fziOMsp8ee3paz9xoRPNIVNliwjgO7A7yWeGof20Y8/5l3CayWOGwZIjW2igs JKnWwP31+CgQZq3RmdyXg9ocMD0J4qcBqGMk2xBD8pGeWG6PsWLP3Lfh8JqtI4c0PvYE IwC7hJ93dJhmAamFXAnNm3Diz4hCPs7fdJJEslNTiN+SV8Z/Gj9y/fbLVg8x+gA2TRuF A1Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WGyXuYg7j5iNtkmXs/iE4hiK+eox8G74tOXvL6PqjnA=; b=jf6+NzSX0zveJCHeGbmdW9yrMskpAofNlguCjJaN9kFFyza0ounI3MlP/dOF2jn66X 9jEGiUdKangGmn7RbYvDfb4YwMzhgYH/VVe8qwHWG6vtq2HEnva1lJQcCA/9MltJPFuD qP9vdt3GFHhQ7smQLwdlDkqixacKnZc870Jx919Q1U5bnw/dMB8nXxuqWv7y92PPculk UHhUAASfgx2YuGBhndewIeysPlXZMzV/pwovlQ5SGGZI2r7LnznDZXfBcjDr5owLRMVw 34qKvLfylnKs6+b7F6OKh3lxc+cEyQOCwPh3BOrzzCIeom+L1mp6y03FNq7v7BADffLU kIEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cRFmOPzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si16288229plg.152.2022.02.08.23.38.33; Tue, 08 Feb 2022 23:38:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cRFmOPzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390842AbiBGL6E (ORCPT + 99 others); Mon, 7 Feb 2022 06:58:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384709AbiBGL3i (ORCPT ); Mon, 7 Feb 2022 06:29:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB891C0401CA; Mon, 7 Feb 2022 03:28:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7784460AB2; Mon, 7 Feb 2022 11:28:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5220DC004E1; Mon, 7 Feb 2022 11:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233283; bh=u3/akX/dz9ZO7Yp9P/0+QWrmMr/uEK5Ppvyr2pAXRic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRFmOPzv10hMTRT6BL48zRmuMEEDXH4g3h5ozIn8i5dK2B5rdCUw1+t3fdGt+aPVb oYuMDz6FCYXcLgduts/z8TuPUtzFYy1BF24mrgzKW4zPEG/zduEbFspwG3d1Ln0/qR UQSvvnU8aRBEc6mREIa5BEmbzhmm0mTtOLp5Dino= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Mark Brown Subject: [PATCH 5.15 074/110] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Date: Mon, 7 Feb 2022 12:06:47 +0100 Message-Id: <20220207103804.801499999@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiasheng Jiang commit f7a6021aaf02088870559f82fc13c58cda7fea1a upstream. If the device does not exist, of_get_child_by_name() will return NULL pointer. And devm_snd_soc_register_component() does not check it. Also, I have noticed that cpcap_codec_driver has not been used yet. Therefore, it should be better to check it in order to avoid the future dereference of the NULL pointer. Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec") Signed-off-by: Jiasheng Jiang Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/codecs/cpcap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -1667,6 +1667,8 @@ static int cpcap_codec_probe(struct plat { struct device_node *codec_node = of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); + if (!codec_node) + return -ENODEV; pdev->dev.of_node = codec_node;