Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932859AbdHVNYz (ORCPT ); Tue, 22 Aug 2017 09:24:55 -0400 Received: from mail-qt0-f171.google.com ([209.85.216.171]:38582 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932657AbdHVNYy (ORCPT ); Tue, 22 Aug 2017 09:24:54 -0400 MIME-Version: 1.0 In-Reply-To: <20170822075729.8438-3-jeffy.chen@rock-chips.com> References: <20170822075729.8438-1-jeffy.chen@rock-chips.com> <20170822075729.8438-3-jeffy.chen@rock-chips.com> From: Donglin Peng Date: Tue, 22 Aug 2017 21:24:32 +0800 Message-ID: Subject: Re: [PATCH v5 2/9] ASoC: soc-core: Allow searching dai driver name in snd_soc_find_dai To: Jeffy Chen Cc: linux-kernel@vger.kernel.org, dgreid@chromium.org, =?UTF-8?Q?Heiko_St=C3=BCbner?= , briannorris@chromium.org, mengdong.lin@linux.intel.com, mka@chromium.org, lars@metafoo.de, dianders@chromium.org, Jaroslav Kysela , alsa-devel@alsa-project.org, Mark Brown , Takashi Iwai , Liam Girdwood Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1002 Lines: 27 Hi jeffy, On Tue, Aug 22, 2017 at 3:57 PM, Jeffy Chen wrote: > @@ -978,7 +978,8 @@ struct snd_soc_dai *snd_soc_find_dai( > if (dlc->name && strcmp(component->name, dlc->name)) > continue; > list_for_each_entry(dai, &component->dai_list, list) { > - if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)) > + if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) > + && strcmp(dai->driver->name, dlc->dai_name)) In case that dai->driver->name is NULL, strcmp(dai->driver->name, dlc->dai_name) will cause segmentation fault. so I think that we can change it as the follows: if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) && dai->driver->name && strcmp(dai->driver->name, dlc->dai_name)) > continue; > > return dai; > -- > 2.11.0 > >