From nobody Fri Apr 17 02:59:30 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 897A41F30A9 for ; Tue, 24 Feb 2026 08:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771922742; cv=none; b=OPkHfWO+W89ZKQkX/7VDnaMB3KbxD63GG4vXvGJMfn1HRJX/NQYAGkDhC3Auv5lMB0U/1zGrRTy9LRORbJGzP8JKh0bRJIgMVy8tvUEXSanvv/qMsXWbuPGghGHaVjMr/OHjkZuiEk7IGbaztsNQjFcxnBFCAryQlMABZaxsIFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771922742; c=relaxed/simple; bh=6GJ7wwpufMKzOCs6Ll7VknfEXZk4guGu+jXTL5einPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oZA4d9vmLqTJY8CPRTYXzPannYXlMKlpuqGPqrhA/ASa7vm8k8qqulJdjPU11Xt3o/enVOocvDvRl3BL9skoW7K98AA9Am11Pt+kgaUDfUUxWFi/0ZZM0j0zYQwZBLm4rNKEt84TdrwDhQhPb39r1kCa7dTQFqzqJHrYdGTuk+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jxOzgkP6; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jxOzgkP6" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-4327790c4e9so3957907f8f.2 for ; Tue, 24 Feb 2026 00:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771922740; x=1772527540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8HGQyoPmmP4igIydqIgyIzKYxgE5L1j9Bpi6YK68BoI=; b=jxOzgkP6txsHpPZm/7RUFRu1ydPA93v7oZ12AhdUS8PoJVlMqiLx2QLzTfxbOKy1Js 9gHqtCNWe+MK1n3L/4uRoHChNohFN2WS/pGMos8PvTUJzD3RGA60MAqgN0xFwGukIlud QduSmiMmWV3YlTZLL/1tortKi+XsKxEDVWRsQNkOWAjm6hYqQ2G0uO/ZxPagkT2hhG9N 5xFQonDTBa0IyU0NrTXE4Q2FCpyG8JDtnSEpqoxQp3HaBpaZERWh0Wk8gzzs9fNr7uXn v+kPzAJVP81UVvxwcujTyoE5rtG07yrVAXsOq4zC8cckCTzj1m8u3C3BXyJtEerAEQTK qKKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771922740; x=1772527540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8HGQyoPmmP4igIydqIgyIzKYxgE5L1j9Bpi6YK68BoI=; b=RhEAzxFzpLNhMmr4jK9WK38aL5iKO633Tp3dUZIh12xq5pEGrzLmz7aywtn1rFH0b2 17Bz1xrqUdP0TZMWfU4y1u+CvIVApsbJ3WmqP18QTTw4PsG37iJ5rlf4J9b24cSnBoJV 7iaMj7zStKhY/UjBifKkGrfzQ7LzAkxx5YQAUAIv6fDFLVbn8SJwaDbZv6l4fGRXiSCu ru1D0BdIixe+unNG6BgNm2akDjmtxnq4ssOQwsu9kmAmgqo/bM9prdEZOUrtEWG0xYFO c3G1pTZWbLrOTRMjhewYmN6W7NrKdYfs4R9OgfR3IGJ3jIf9G0ozDdPdua/Z9ufD7cWb KVCg== X-Forwarded-Encrypted: i=1; AJvYcCVFzWrnarOq+eZsn1OWzCvJOplqbn8g1dif5HGQClh7dtVYqpvXItbSkvdF5/v4PSf3c8bpPTVmLvDZBIA=@vger.kernel.org X-Gm-Message-State: AOJu0YzDHjcMfVjs0fRd/0ZaNMYGDBRLOQh17EdLq97KJcOQMuBuBehu 5sYlXXhOy6mbKsHuSvnKCpcBBzbV+LZqDBvsJUHZnEbjODcTe6eyxfzH X-Gm-Gg: ATEYQzz7lC/khs6TAZYDcgFeMdzLzmPRA0YzcisS7subOreXO90wLxDEYEijrm68JC8 Iu2F3t7AxN9PCZ1fy5hzl3Z0aV+IkS8J3Omkoewdvx+7Bw1oxmBuJVtlBD8L6QquDuLa46dtwi8 XoQQcvC10Pm3GVkmC/tqQ63ULBDA0W4c+eAe2WzBm3OLDvzq7FIbqgQXsD5ZxQ3Ddbl3xKiBpuL s0n/zwBLOeWImPd92WWF0tHQ9FqLUtmORnRCcBxlpN4a+V4CkdsyfOEakeSE08fp+7TybvCtaQx QV5SMVuBZvJpbN0/+6jlshTyph8z9eEvzxJ2M1ENeFmY1FbZDt8BUo2gb1ts/8DlM6ZnavnhFrs F4QCARCMTlA0nIBWZyrzYBrC+bxh3TDWhXHmbD0w6Moaj3nFFDg620Wi3SOrGj4J7OmPz36Jyj2 c3d3FWCPDw4+ZSQ9P6vp24GLIlBse+tQ8zp3tg5EE= X-Received: by 2002:a05:6000:230c:b0:436:233c:c7bb with SMTP id ffacd0b85a97d-4396f194541mr20839944f8f.27.1771922739724; Tue, 24 Feb 2026 00:45:39 -0800 (PST) Received: from localhost.localdomain ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970d4c626sm27941713f8f.28.2026.02.24.00.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 00:45:38 -0800 (PST) From: "Jose A. Perez de Azpillaga" To: vaibhav.sr@gmail.com, mgreer@animalcreek.com Cc: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH v2] staging: greybus: move topology allocation to codec probe Date: Tue, 24 Feb 2026 09:44:23 +0100 Message-ID: <20260224084508.88867-1-azpijr@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260223195939.71151-1-azpijr@gmail.com> References: <20260223195939.71151-1-azpijr@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The FIXME in gb_audio_probe noted that memory allocation for the topology should happen within the codec driver rather than the greybus helper. Move the size-check and kzalloc from audio_gb.c to audio_module.c and update the function signature of gb_audio_gb_get_topology to accept the pointer. This clarifies ownership of the allocated memory. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202602240844.4eT24iVh-lkp@int= el.com/ Signed-off-by: Jose A. Perez de Azpillaga --- v2: - Fixed build error by updating function prototype in audio_codec.h. - Fixed 'struct gb_audio_topology has no member named size' by passing size as an explicit argument to gb_audio_gb_get_topology(). --- drivers/staging/greybus/audio_codec.h | 2 +- drivers/staging/greybus/audio_gb.c | 33 +++----------------------- drivers/staging/greybus/audio_module.c | 27 +++++++++++++++++---- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybu= s/audio_codec.h index f3f7a7ec6be4..2d7c3f928b1d 100644 --- a/drivers/staging/greybus/audio_codec.h +++ b/drivers/staging/greybus/audio_codec.h @@ -179,7 +179,7 @@ void gbaudio_unregister_module(struct gbaudio_module_in= fo *module); /* protocol related */ int gb_audio_gb_get_topology(struct gb_connection *connection, - struct gb_audio_topology **topology); + struct gb_audio_topology *topology, u16 size); int gb_audio_gb_get_control(struct gb_connection *connection, u8 control_id, u8 index, struct gb_audio_ctl_elem_value *value); diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/a= udio_gb.c index 9d8994fdb41a..8459a6d6f289 100644 --- a/drivers/staging/greybus/audio_gb.c +++ b/drivers/staging/greybus/audio_gb.c @@ -8,38 +8,11 @@ #include #include "audio_codec.h" -/* TODO: Split into separate calls */ int gb_audio_gb_get_topology(struct gb_connection *connection, - struct gb_audio_topology **topology) + struct gb_audio_topology *topology, u16 size) { - struct gb_audio_get_topology_size_response size_resp; - struct gb_audio_topology *topo; - u16 size; - int ret; - - ret =3D gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE, - NULL, 0, &size_resp, sizeof(size_resp)); - if (ret) - return ret; - - size =3D le16_to_cpu(size_resp.size); - if (size < sizeof(*topo)) - return -ENODATA; - - topo =3D kzalloc(size, GFP_KERNEL); - if (!topo) - return -ENOMEM; - - ret =3D gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, NULL, 0, - topo, size); - if (ret) { - kfree(topo); - return ret; - } - - *topology =3D topo; - - return 0; + return gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, + NULL, 0, topology, size); } EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology); diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greyb= us/audio_module.c index 12c376c477b3..84c591b59b4e 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -240,6 +240,8 @@ static int gb_audio_probe(struct gb_bundle *bundle, struct gbaudio_data_connection *dai, *_dai; int ret, i; struct gb_audio_topology *topology; + struct gb_audio_get_topology_size_response size_resp; + u16 size; /* There should be at least one Management and one Data cport */ if (bundle->num_cports < 2) @@ -304,13 +306,28 @@ static int gb_audio_probe(struct gb_bundle *bundle, } gbmodule->dev_id =3D gbmodule->mgmt_connection->intf->interface_id; - /* - * FIXME: malloc for topology happens via audio_gb driver - * should be done within codec driver itself - */ - ret =3D gb_audio_gb_get_topology(gbmodule->mgmt_connection, &topology); + ret =3D gb_operation_sync(gbmodule->mgmt_connection, + GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE, NULL, 0, + &size_resp, sizeof(size_resp)); + if (ret) + goto disable_connection; + + size =3D le16_to_cpu(size_resp.size); + if (size < sizeof(*topology)) { + ret =3D -ENODATA; + goto disable_connection; + } + + topology =3D kzalloc(size, GFP_KERNEL); + if (!topology) { + ret =3D -ENOMEM; + goto disable_connection; + } + + ret =3D gb_audio_gb_get_topology(gbmodule->mgmt_connection, topology, siz= e); if (ret) { dev_err(dev, "%d:Error while fetching topology\n", ret); + kfree(topology); goto disable_connection; } -- 2.53.0