Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2032969rwb; Thu, 17 Nov 2022 05:47:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7QbOtfZtWI7PkQXUhovQBOD+zuk1cVpuW9RAnhpyOaDtZxs2YKCC3a2kWVC8dtnC5u5lbI X-Received: by 2002:a17:906:4309:b0:78d:36d7:92ae with SMTP id j9-20020a170906430900b0078d36d792aemr2267496ejm.113.1668692855835; Thu, 17 Nov 2022 05:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668692855; cv=none; d=google.com; s=arc-20160816; b=aNXpZSwWWj4WjuwHvfLNrleOsnkZnqmPlX33/8EX3hDVsn7WzL6qOOf39IL/7M8FQK pxokEUxurio40tUpPYIycnYLsm2I2JQJ1tjA+jWoXq14R1yGYQ8GF509h2PXtvKlFJbc nX1J2wjDnzhRWWzQQ96QT2ROdDCsq93/vqNlm3W2Px20nJvG5Lif2DhlDB9f7NERXWqL 2+YKRpPiRC+04lWOpx2K3lV1T7Er5wM/929sABEtfUTie+wPHuImiAb6B5Lvhbw33ina tjUTiSlmMn1cUIQc8yO17KKbkTH2ddLhS9kVm34EJQvD78qmv7PhmL5y5BwW830riZ4C 4jJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=83/dPJviRTYaF9ZKp7pLopYYxEGjtqXxqsKXv1lSIqo=; b=BQ73Q9IBki0PznP5UpZph982skOk2ZWnAZXOAKXSsYeJnJGMsC91TJjZyTMF6AlQHw fIn3B0XByMlyexduE7UvN7ruyNUE8ZtbOzv98SaSSnmUV2nrEPpoHwC19nBtyuOBlwbA s9Y+6IkAB3BgRxCb8jW3L6Nz7SgmDIwG4MnwcP0Wmuxz2yqrFpPXqlNIWrXBK6JmKYBS jSS7IHCZdLLQc9NCmQEPLIAaJZhRbO6iHQCo/hiXZPBuu8zjNyvZUHjylAtvV/DAycxQ oimS4hyAn1mSSBQCOQLZNYay6GHNL2OcCHmoRehGrtvk5KdbuCjwBcomDKdkvgsmgrQa xeVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PqQwHRCH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a17090658cc00b007ae6869f9d9si689445ejs.419.2022.11.17.05.47.13; Thu, 17 Nov 2022 05:47:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PqQwHRCH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240140AbiKQNhR (ORCPT + 93 others); Thu, 17 Nov 2022 08:37:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240136AbiKQNhO (ORCPT ); Thu, 17 Nov 2022 08:37:14 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B1D57341C for ; Thu, 17 Nov 2022 05:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668692233; x=1700228233; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=S2LL1Qvk1qH+6CRpB+yCup1YqVOGXcciNvz60LpQwfM=; b=PqQwHRCHm8KskEKglh594kF41cT8a1N1lY6TYuqRPsNu3derYQB6s9XJ Kwd1BKSNoYGSb81tBkRnT2C1NBNqgPwTNKjk/fz6lMu3CqD0DpOdE2OFb xQKY05ypv/f8+EY8L708zG4acAAdokNbIYn11kM4BWhVpTDKEclU8rHFJ fmQGaYuT1d0XXB5TT5kmc5AGVSkpuGx7LWJeGFIE2euPUsVUBFQTZFJLM xei/zENmpTafSDiIfUd8/ostGcqmSzk8NZqCkGuGfB5Zndk4zfu2ky+2Y Lz/F7ioqMmaIyTknmUloM/LWc/n+GCENu0gfTJ7OHbx/WmGlIG2vGFsPb Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="292556307" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="292556307" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 05:37:13 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="590622508" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590622508" Received: from crequinx-mobl1.ger.corp.intel.com (HELO [10.252.19.12]) ([10.252.19.12]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 05:37:09 -0800 Message-ID: <4942f328-8bb6-9880-8901-0cae5ca73873@linux.intel.com> Date: Thu, 17 Nov 2022 15:37:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.4.2 Subject: Re: [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation To: Andy Shevchenko , Mark Brown , Pierre-Louis Bossart , Ranjani Sridharan , Jyri Sarha , sound-open-firmware@alsa-project.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Liam Girdwood , Bard Liao , Kai Vehmanen , Daniel Baluta , Jaroslav Kysela , Takashi Iwai References: <20221117103223.74425-1-andriy.shevchenko@linux.intel.com> Content-Language: en-US From: =?UTF-8?Q?P=c3=a9ter_Ujfalusi?= In-Reply-To: <20221117103223.74425-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE 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 On 17/11/2022 12:32, Andy Shevchenko wrote: > We may check ops before spending resources on memory allocation. we might. Acked-by: Peter Ujfalusi > While at it, utilize dev_get_platdata() helper. > > Signed-off-by: Andy Shevchenko > --- > sound/soc/sof/sof-client-probes.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c > index d08395182b1a..fff126808bc0 100644 > --- a/sound/soc/sof/sof-client-probes.c > +++ b/sound/soc/sof/sof-client-probes.c > @@ -399,23 +399,21 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev, > if (!sof_probes_enabled) > return -ENXIO; > > - if (!dev->platform_data) { > + ops = dev_get_platdata(dev); > + if (!ops) { > dev_err(dev, "missing platform data\n"); > return -ENODEV; > } > - > - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > - if (!priv) > - return -ENOMEM; > - > - ops = dev->platform_data; > - > if (!ops->startup || !ops->shutdown || !ops->set_params || !ops->trigger || > !ops->pointer) { > dev_err(dev, "missing platform callback(s)\n"); > return -ENODEV; > } > > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > priv->host_ops = ops; > > switch (sof_client_get_ipc_type(cdev)) { -- Péter