Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1577047pxb; Tue, 8 Feb 2022 22:53:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4K/OshBjrlWW3g+2L4upw+gTLTpkJdltuH2ZaKkwuVXa/GkcxTiOyQrMvDECLAHNDG0Ew X-Received: by 2002:a17:902:dac7:: with SMTP id q7mr755691plx.125.1644389633539; Tue, 08 Feb 2022 22:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389633; cv=none; d=google.com; s=arc-20160816; b=NboIPY+0zplcs6/MQ/CCZNo6uMKNUOR+0SXxfPSQbeushuOu131jybRYbrJCQ7d5Va uDn0lEfUyK2oNYnj6I52Nk3I850Y3x/4/cybGvEimXzM5QpWkXGmLbNl2vq8FPHkgF4+ 5NPozKBQcvYgaH717oyvEjGvFnbF6bFRg4MMmE3wpDeRSNww6WoXsVdtCD6IhexT5SFW EiKFSgOs5nC906EkDj2UOka9o8vyuryomcTIUL7Jx0WuMcfR+xgt9dMQ5pWILJZ22P8I kPD+aNcRorx2KEDo6MT1ojWr5v8iPvOt3KX5DPgdpJYpk4lwXy36KKhgKvilSlixIkqz 7xyw== 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=ApbDGca3/yvQf2fz436XTReJn0Ccuipb4Iz27wksHGQZSwRR0R6fplUjhOlDq18jF1 +3bUmqLn5Fd8lip+Ozro6CSrhuY0k6ejFitdh9H8xdVdm526P51h2cfGI/wTL8Oyp/3E qmTxN5MKy33XwPJus/Sesznc/3kjQrPNlyE2220/BRvF8xQEsUhaTKAQEzVtgffEmdPr pMCFVSByL3aKWwM74ZFaWSvh56FY+4xN3smHbsMXiiIdE8r3E9vLJE263dGUQDIyJBR0 nDbdciBZnyPZpbL4UyYApDYURNwT2zvH2+WYxLSwDP/Rp5M9JWegA3Ro5OsPHuBqqMV4 xFbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="t5xaD/2l"; 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 d6si15548558pgc.95.2022.02.08.22.53.41; Tue, 08 Feb 2022 22:53:53 -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="t5xaD/2l"; 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 S1389366AbiBGLsY (ORCPT + 99 others); Mon, 7 Feb 2022 06:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386505AbiBGLes (ORCPT ); Mon, 7 Feb 2022 06:34:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7546C043188; Mon, 7 Feb 2022 03:34:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id 93480B8102E; Mon, 7 Feb 2022 11:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84BA3C004E1; Mon, 7 Feb 2022 11:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233685; bh=u3/akX/dz9ZO7Yp9P/0+QWrmMr/uEK5Ppvyr2pAXRic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5xaD/2lVVp7c10OGGCY4dM0ctnj/8/lPZuvw9wSxgmcXEAzdwR9AtCqcueAUVjRR i/R2xT0SJC4l1+xIxnNkOYyELp9V/D4/wLyX1CGGNqVunfpXiG/pPKMwVGC65QJTk/ GkXnu7B6tJ5lT5nqVxIbxGsqKosV6qo7iHKSMW/o= 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.16 087/126] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Date: Mon, 7 Feb 2022 12:06:58 +0100 Message-Id: <20220207103807.103050951@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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;