From patchwork Thu Oct 27 07:12:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengdong.lin@linux.intel.com X-Patchwork-Id: 9399151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB6E760588 for ; Thu, 27 Oct 2016 10:19:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D085B2A13B for ; Thu, 27 Oct 2016 10:19:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3CA82A13E; Thu, 27 Oct 2016 10:19:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 526B42A13B for ; Thu, 27 Oct 2016 10:18:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9E7FE26738F; Thu, 27 Oct 2016 12:18:58 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 34415267355; Thu, 27 Oct 2016 12:16:40 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6FEF326731C; Thu, 27 Oct 2016 09:11:01 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by alsa0.perex.cz (Postfix) with ESMTP id D180D2672CA for ; Thu, 27 Oct 2016 09:10:51 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 27 Oct 2016 00:10:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,404,1473145200"; d="scan'208";a="24291897" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by orsmga005.jf.intel.com with ESMTP; 27 Oct 2016 00:10:47 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Thu, 27 Oct 2016 15:12:06 +0800 Message-Id: <71fe37d22156ec663c2841e994c4881b9678ed78.1477549962.git.mengdong.lin@linux.intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: Mengdong Lin , tiwai@suse.de, hardik.t.shah@intel.com, guneshwor.o.singh@intel.com, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, broonie@kernel.org, mengdong.lin@intel.com Subject: [alsa-devel] [PATCH 06/22] topology: tplg_elem_lookup() checks parameter before searching X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin Check the parameters at first in case of misuse. Signed-off-by: Mengdong Lin diff --git a/src/topology/elem.c b/src/topology/elem.c index 029c9ab..724bf26 100644 --- a/src/topology/elem.c +++ b/src/topology/elem.c @@ -111,6 +111,9 @@ struct tplg_elem *tplg_elem_lookup(struct list_head *base, const char* id, struct list_head *pos; struct tplg_elem *elem; + if (!base || !id) + return NULL; + list_for_each(pos, base) { elem = list_entry(pos, struct tplg_elem, list);