From 2508038a28e46a4177c727bd16671840cddc20a2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 27 Aug 2020 13:09:35 -0500 Subject: [PATCH 1/2] fixup! ASoC: SOF: Implement snd_sof_bytes_ext_volatile_get kcontrol IO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix compilation warning in i386 mode. sound/soc/sof/control.c: In function ‘snd_sof_bytes_ext_volatile_get’: sound/soc/sof/control.c:388:35: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=] 388 | dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %lu.\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/control.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index 1fe6a1c12523c5..589bd5b4490e7d 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -388,8 +388,9 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _ /* check data size doesn't exceed max coming from topology */ if (cdata->data->size > be->max - sizeof(const struct sof_abi_hdr)) { - dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %lu.\n", - cdata->data->size, be->max - sizeof(const struct sof_abi_hdr)); + dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %zu.\n", + cdata->data->size, + (size_t)be->max - sizeof(const struct sof_abi_hdr)); ret = -EINVAL; goto out; } From 366e03c1eaacb57669eaffe9d462de8f281a07b3 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 28 Aug 2020 17:15:39 -0500 Subject: [PATCH 2/2] fixup! ASoC: SOF: fix range checks The mix of integer and size_t generates different results in 32- and 64 bit mode, cast to size_t and use %zu format. Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/control.c | 13 +++++++------ sound/soc/sof/topology.c | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index 589bd5b4490e7d..b7dc430f52e88f 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -232,8 +232,8 @@ int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, /* be->max has been verified to be >= sizeof(struct sof_abi_hdr) */ if (data->size > be->max - sizeof(*data)) { dev_err_ratelimited(scomp->dev, - "error: %u bytes of control data is invalid, max is %lu\n", - data->size, be->max - sizeof(*data)); + "error: %u bytes of control data is invalid, max is %zu\n", + data->size, (size_t)be->max - sizeof(*data)); return -EINVAL; } @@ -266,8 +266,8 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, /* be->max has been verified to be >= sizeof(struct sof_abi_hdr) */ if (data->size > be->max - sizeof(*data)) { dev_err_ratelimited(scomp->dev, - "error: data size too big %u bytes max is %lu\n", - data->size, be->max - sizeof(*data)); + "error: data size too big %u bytes max is %zu\n", + data->size, (size_t)be->max - sizeof(*data)); return -EINVAL; } @@ -441,8 +441,9 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, /* check data size doesn't exceed max coming from topology */ if (cdata->data->size > be->max - sizeof(const struct sof_abi_hdr)) { - dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %lu.\n", - cdata->data->size, be->max - sizeof(const struct sof_abi_hdr)); + dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %zu.\n", + cdata->data->size, + (size_t)be->max - sizeof(const struct sof_abi_hdr)); return -EINVAL; } diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 6e877e56e7fbd1..3fdce50aa07e21 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1162,8 +1162,8 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp, /* init the get/put bytes data */ if (priv_size > max_size - sizeof(struct sof_ipc_ctrl_data)) { - dev_err(scomp->dev, "err: bytes data size %lu exceeds max %lu.\n", - priv_size, max_size - sizeof(struct sof_ipc_ctrl_data)); + dev_err(scomp->dev, "err: bytes data size %zu exceeds max %zu.\n", + priv_size, (size_t)max_size - sizeof(struct sof_ipc_ctrl_data)); ret = -EINVAL; goto out; }