[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dd3fd255-4397-80d6-2114-3b37b5be5c08@collabora.com>
Date: Mon, 15 Mar 2021 11:39:27 +0100
From: Enric Balletbo i Serra <enric.balletbo@...labora.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
alsa-devel@...a-project.org
Cc: tiwai@...e.de, broonie@...nel.org, linux-kernel@...r.kernel.org,
Cheng-Yi Chiang <cychiang@...omium.org>,
Guenter Roeck <groeck@...omium.org>,
Liam Girdwood <lgirdwood@...il.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Benson Leung <bleung@...omium.org>
Subject: Re: [PATCH 04/23] ASoC: cros_ec_codec: remove null pointer
dereference warning
Hi Pierre-Louis,
Thank you for you patch.
On 12/3/21 19:22, Pierre-Louis Bossart wrote:
> Cppcheck complains of a possible issue:
>
> sound/soc/codecs/cros_ec_codec.c:98:10: warning: Possible null pointer
> dereference: in [nullPointer]
> memcpy(in, msg->data, insize);
> ^
> sound/soc/codecs/cros_ec_codec.c:162:34: note: Calling function
> 'send_ec_host_command', 5th argument 'NULL' value is 0
> (uint8_t *)&p, sizeof(p), NULL, 0);
> ^
> sound/soc/codecs/cros_ec_codec.c:98:10: note: Null pointer dereference
> memcpy(in, msg->data, insize);
> ^
>
> In practice the access to the pointer is protected by another
> argument, but this is likely to fool other static analysis tools. Add
> a test to avoid doing the memcpy if the pointer is NULL or the size is
> zero.
>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Looks good to me, so
Acked-by: Enric Balletbo i Serra <enric.balletbo@...labora.com>
> ---
> sound/soc/codecs/cros_ec_codec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
> index c4772f82485a..a201d652aca2 100644
> --- a/sound/soc/codecs/cros_ec_codec.c
> +++ b/sound/soc/codecs/cros_ec_codec.c
> @@ -94,7 +94,7 @@ static int send_ec_host_command(struct cros_ec_device *ec_dev, uint32_t cmd,
> if (ret < 0)
> goto error;
>
> - if (insize)
> + if (in && insize)
> memcpy(in, msg->data, insize);
>
> ret = 0;
>
Powered by blists - more mailing lists