From patchwork Thu Nov 3 23:08:27 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: 9412113 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 B6C59601C2 for ; Fri, 4 Nov 2016 08:57:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A04A2B006 for ; Fri, 4 Nov 2016 08:57:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7B72B055; Fri, 4 Nov 2016 08:57:46 +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 E7CF22B006 for ; Fri, 4 Nov 2016 08:57:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 69BC0267455; Fri, 4 Nov 2016 09:57:44 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E7DEE267453; Fri, 4 Nov 2016 09:55:18 +0100 (CET) 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 3586F267371; Fri, 4 Nov 2016 00:07:08 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id 84503266BC4 for ; Fri, 4 Nov 2016 00:07:01 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 03 Nov 2016 16:07:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,440,1473145200"; d="scan'208"; a="1080319042" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga002.fm.intel.com with ESMTP; 03 Nov 2016 16:06:59 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Fri, 4 Nov 2016 07:08:27 +0800 Message-Id: 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 6/6] 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);