All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ASoC: snd_soc_component_driver has snd_compr_ops
@ 2018-01-16 11:12 Dan Carpenter
  2018-01-16 11:14 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-01-16 11:12 UTC (permalink / raw)
  To: kuninori.morimoto.gx; +Cc: alsa-devel

Hello Kuninori Morimoto,

The patch 9e7e3738ab0e: "ASoC: snd_soc_component_driver has
snd_compr_ops" from Oct 11, 2017, leads to the following static
checker warning:

	sound/soc/soc-compress.c:109 soc_compr_open()
	warn: 'cstream->runtime->private_data' double freed

sound/soc/soc-compress.c
    91          return 0;
    92  
    93  machine_err:
    94          for_each_rtdcom(rtd, rtdcom) {
    95                  component = rtdcom->component;
    96  
    97                  /* ignore duplication for now */
    98                  if (platform && (component == &platform->component))
    99                          continue;
   100  
   101                  if (!component->driver->compr_ops ||
   102                      !component->driver->compr_ops->free)
   103                          continue;
   104  
   105                  component->driver->compr_ops->free(cstream);
                                                    ^^^^^^^^^^^^^^^
This is in a loop so is the really right?  We end up freeing cstream
over and over?

   106          }
   107  
   108          if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
   109                  platform->driver->compr_ops->free(cstream);
                                                    ^^^^^^^^^^^^^
This second call is what triggers the warning.

   110  plat_err:
   111          if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
   112                  cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
   113  out:
   114          mutex_unlock(&rtd->pcm_mutex);
   115          return ret;
   116  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] ASoC: snd_soc_component_driver has snd_compr_ops
  2018-01-16 11:12 [bug report] ASoC: snd_soc_component_driver has snd_compr_ops Dan Carpenter
@ 2018-01-16 11:14 ` Dan Carpenter
  2018-01-17  0:26   ` Kuninori Morimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-01-16 11:14 UTC (permalink / raw)
  To: kuninori.morimoto.gx; +Cc: alsa-devel

See also:

sound/soc/soc-compress.c:245 soc_compr_open_fe() warn: 'cstream->runtime->private_data' double freed
sound/soc/soc-compress.c:329 soc_compr_free() warn: 'cstream->runtime->private_data' double freed
sound/soc/soc-compress.c:413 soc_compr_free_fe() warn: 'cstream->runtime->private_data' double freed

regards,
dan carpenter

On Tue, Jan 16, 2018 at 02:12:42PM +0300, Dan Carpenter wrote:
> Hello Kuninori Morimoto,
> 
> The patch 9e7e3738ab0e: "ASoC: snd_soc_component_driver has
> snd_compr_ops" from Oct 11, 2017, leads to the following static
> checker warning:
> 
> 	sound/soc/soc-compress.c:109 soc_compr_open()
> 	warn: 'cstream->runtime->private_data' double freed
> 
> sound/soc/soc-compress.c
>     91          return 0;
>     92  
>     93  machine_err:
>     94          for_each_rtdcom(rtd, rtdcom) {
>     95                  component = rtdcom->component;
>     96  
>     97                  /* ignore duplication for now */
>     98                  if (platform && (component == &platform->component))
>     99                          continue;
>    100  
>    101                  if (!component->driver->compr_ops ||
>    102                      !component->driver->compr_ops->free)
>    103                          continue;
>    104  
>    105                  component->driver->compr_ops->free(cstream);
>                                                     ^^^^^^^^^^^^^^^
> This is in a loop so is the really right?  We end up freeing cstream
> over and over?
> 
>    106          }
>    107  
>    108          if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
>    109                  platform->driver->compr_ops->free(cstream);
>                                                     ^^^^^^^^^^^^^
> This second call is what triggers the warning.
> 
>    110  plat_err:
>    111          if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
>    112                  cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
>    113  out:
>    114          mutex_unlock(&rtd->pcm_mutex);
>    115          return ret;
>    116  }
> 
> regards,
> dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] ASoC: snd_soc_component_driver has snd_compr_ops
  2018-01-16 11:14 ` Dan Carpenter
@ 2018-01-17  0:26   ` Kuninori Morimoto
  0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2018-01-17  0:26 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel


Hi Dan

Thank you for your report

> >     93  machine_err:
> >     94          for_each_rtdcom(rtd, rtdcom) {
> >     95                  component = rtdcom->component;
> >     96  
> >     97                  /* ignore duplication for now */
> >     98                  if (platform && (component == &platform->component))
> >     99                          continue;
> >    100  
> >    101                  if (!component->driver->compr_ops ||
> >    102                      !component->driver->compr_ops->free)
> >    103                          continue;
> >    104  
> >    105                  component->driver->compr_ops->free(cstream);
> >                                                     ^^^^^^^^^^^^^^^
> > This is in a loop so is the really right?  We end up freeing cstream
> > over and over?
> > 
> >    106          }
> >    107  
> >    108          if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
> >    109                  platform->driver->compr_ops->free(cstream);
> >                                                     ^^^^^^^^^^^^^

In for_each_rtdcom(), it is checking and avoiding duplicate operation by

	/* ignore duplication for now */
	if (platform && (component == &platform->component))
		continue;

So, I think there is no double free ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-17  0:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 11:12 [bug report] ASoC: snd_soc_component_driver has snd_compr_ops Dan Carpenter
2018-01-16 11:14 ` Dan Carpenter
2018-01-17  0:26   ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.