Skip to contentSkip to conversation

Question on compress offload framework memory corruption

DISCUSSION [email protected] 4 participants 5 messages Dec 18, 2013 – Jan 5, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

I have following questions in the compressed offload framework API.

static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
...

	hw_params = kzalloc(sizeof(*hw_params), GFP_KERNEL);
	if (hw_params == NULL)
		return -ENOMEM;

/*1st question is, what is the use of above allocated memory I do not see this being used in this function*/

...

	memcpy(&fe->dpcm[fe_substream->stream].hw_params, params,
			sizeof(struct snd_pcm_hw_params));

/* 2nd question is
in above memcpy there is parameter mismatch &fe->dpcm[fe_substream->stream].hw_params is of structure type struct snd_pcm_hw_params

params argument is of the structure type struct snd_compr_params the definition of the two structures are different, how this is working? this will over right the destination with junk value which will return in error when this memory is accessed, after memcpy this cpu_dai hw_params returing with EINVAL error, please explain why this is done this way. */

...

}

Regards,
Santosh M G.

#1 lore raw

Re sending this as i did not got the response.

--Santosh

Quoted 40 lines

Hi,

I have following questions in the compressed offload framework API.

static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
...

	hw_params = kzalloc(sizeof(*hw_params), GFP_KERNEL);
	if (hw_params == NULL)
		return -ENOMEM;

/*1st question is, what is the use of above allocated memory I do not see this being used in this function*/

...

	memcpy(&fe->dpcm[fe_substream->stream].hw_params, params,
			sizeof(struct snd_pcm_hw_params));

/* 2nd question is
in above memcpy there is parameter mismatch &fe->dpcm[fe_substream->stream].hw_params is of structure type struct snd_pcm_hw_params

params argument is of the structure type struct snd_compr_params the definition of the two structures are different, how this is working? this will over right the destination with junk value which will return in error when this memory is accessed, after memcpy this cpu_dai hw_params returing with EINVAL error, please explain why this is done this way. */

...

}

Regards,
Santosh M G.

#2 lore raw
In reply to [email protected]

Re-sending with Liam's correct address (which is _not_ [email protected]).

Quoted 37 lines · [email protected] wrote:

Hi,

I have following questions in the compressed offload framework API.

static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
...

	hw_params = kzalloc(sizeof(*hw_params), GFP_KERNEL);
	if (hw_params == NULL)
		return -ENOMEM;

/*1st question is, what is the use of above allocated memory I do not see this being used in this function*/

...

	memcpy(&fe->dpcm[fe_substream->stream].hw_params, params,
			sizeof(struct snd_pcm_hw_params));

/* 2nd question is
in above memcpy there is parameter mismatch &fe->dpcm[fe_substream->stream].hw_params is of structure type struct snd_pcm_hw_params

params argument is of the structure type struct snd_compr_params the definition of the two structures are different, how this is working? this will over right the destination with junk value which will return in error when this memory is accessed, after memcpy this cpu_dai hw_params returing with EINVAL error, please explain why this is done this way. */

...

}

Regards,
Santosh M G.

#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, Dec 18, 2013 at 01:17:51PM -0000, [email protected] wrote:

Hi,

I have following questions in the compressed offload framework API.

static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
...

Quoted 5 lines
	hw_params = kzalloc(sizeof(*hw_params), GFP_KERNEL);
	if (hw_params == NULL)
		return -ENOMEM;

/*1st question is, what is the use of above allocated memory I do not see this being used in this function*/

The code you're quoting there isn't in mainline. I've also added Vinod to the CCs, you probably want to include him in any discussion of the compressed API.

#4 lore raw
Quoted 15 lines · Mark Brown
Quoted 8 lines · On Wed, Dec 18, 2013 at 01:17:51PM -0000, [email protected] wrote:

Hi,

I have following questions in the compressed offload framework API.

static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
struct snd_compr_params *params)
{
...

Quoted 5 lines
	hw_params = kzalloc(sizeof(*hw_params), GFP_KERNEL);
	if (hw_params == NULL)
		return -ENOMEM;

/*1st question is, what is the use of above allocated memory I do not see this being used in this function*/

Quoted 3 lines

The code you're quoting there isn't in mainline. I've also added Vinod to the CCs, you probably want to include him in any discussion of the compressed API.

That's right, this is from DPCM compressed updated done by Liam, so he is the best person to comment on this bit, and somehow his address in CC has gone bad, i have added him in to list

But yes looking at the source, i agree that two are interlinked.
I guess we need to poupulate the hw_params and then use that to copy, that would be the right thing to do here and yes this is not correct and not sure how this is working...

Signature · 1 line
~Vinod