Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1831329rwb; Thu, 17 Nov 2022 02:40:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4V0+8w9vhpNO/tdwkMuEdmlXa8ruGl++Mz4+tuPL0/4Yw0YLOHFJ2zwp3Igmmakc45wNKR X-Received: by 2002:a63:5d63:0:b0:462:85d6:6276 with SMTP id o35-20020a635d63000000b0046285d66276mr1532691pgm.293.1668681641887; Thu, 17 Nov 2022 02:40:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668681641; cv=none; d=google.com; s=arc-20160816; b=ILYI6+7bYscABddQ076klhEXSaxwsHuFDbregwpvcaLBlDHTOdGIsRFfIH5VXYj3XP hlbhp4XnddxTa4JZLjgWT6XJVSAjGHkkaJ98moP1x+5AbSdUULaIWZoDAGFm3R+NnzP9 /viuUz47C6wA3JJKC4mVPL/OaqHPl8uOJtElRDSwUOe12xzMqj8TqeVb8kv/TZwnZNCI IToJsObycV8dgiJZ0nMeCsAj5SV6aTBY60QlIw+waCL94nkHB8jP1Eax5lkUxlqlSxw+ 06NxTmVF2D5TewU6C9jhmJPCIsh8lQh6hPQpqzrlFXYYVaNZJ9fH20PwlyO2QIjr68hZ eU3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=lRg2dbJRJPug5kMS5w3eVi3Ze6R+dB9YAf7cNYhxqQU=; b=rQf4tTua0NO2JMdW5bSMnhYzjifbLGGpi636Gi0a2Fz4g1U3OJvVUZTzIE38cC4u7b 3Ad8y1zeKxByyKGswMpQ/TnsawrZmLykdh4eLtcdjg5G6ylwA5ySG6NRVjONIYY73cpb ShJ8XPgmEf5gktUMeW2HXWifTs+tiICWP8rKgRB5wbYzUBRxxNXVTWA2F9SS6nAyrN3J b1ZGR10FAXMK3eHsiXAijW04bj/wCGe5A2X74BRbIVDlwnnMGCS0nESKzbJ6iWPSxt9q CaftnYlwpdsOkK6CVKNKsLqbl76tBgs2bvGDdJFynu+YZgzT9fqKz7CDb5RPP8POVKzB q+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="VOX/qhzP"; 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 d3-20020a655883000000b0046ed85dbdf5si779630pgu.100.2022.11.17.02.40.30; Thu, 17 Nov 2022 02:40:41 -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="VOX/qhzP"; 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 S239477AbiKQKcI (ORCPT + 92 others); Thu, 17 Nov 2022 05:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbiKQKcG (ORCPT ); Thu, 17 Nov 2022 05:32:06 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A060D59841 for ; Thu, 17 Nov 2022 02:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668681125; x=1700217125; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CpdbmDBh5RulsmM2sjgVaOibIHHXUwZtdOLMVaFIP3s=; b=VOX/qhzPKdmAkjNnvjIFY7DCgGuB4QFDBISFaQ3Gaw8/jwSwfFTVjeVV CPMOHoRqHesTRDGq4/5FI6SLJoCc9i8r+RoN9fIhIV6lXSNTYjjj6OgJv HmeZvWPTpEwIUaCQYVXu0gL/zMiy1IiRi7dCEtAHqjYsrXSUIgjbVHH0d neq21ATMkBY85X5dEl8GdK9TFeHl9pwWb9UAXI2klubDKsiyN5AtGgpvw yjNzCRWGi1FOs2jnO0EOQiF7ZW1hbVsuGbBHNUfDnrVFdFBOQqRZEWD0w ThXQQbsmiWGm4a+MjHaXHFGRdpjTixeUrbf1IwNK8TfM2poRoUc1QX4X4 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="313965339" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="313965339" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 02:32:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="764711982" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="764711982" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 17 Nov 2022 02:32:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E866810E; Thu, 17 Nov 2022 12:32:25 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Peter Ujfalusi , 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 , Andy Shevchenko Subject: [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation Date: Thu, 17 Nov 2022 12:32:23 +0200 Message-Id: <20221117103223.74425-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 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,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,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 We may check ops before spending resources on memory allocation. 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)) { -- 2.35.1