[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug report] ALSA: xen-front: Use Xen common shared buffer implementation


  • To: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 27 Oct 2020 07:37:29 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6ma5D9kE2vB48ZRnF982ee4/AEojb/VS+Y+GsInweVY=; b=FBKTLOy++lcQ2abp5Evw88TeGdZQNXWkH4Uxvs3rdS5tnsdDbgTx9Mdwfbuzzsm4no1t3VsGu8WIqNYGzVe6HHicxDP/ayDl12ao5mo1CnTfl09Sfgy/B88sICat72pQkiBZsVS7nEsmtOXy7bi1pL/WgRAmQu3W7Zxmrlt51wTfqMbCioNFbPBX3osb46EGBpdtpArKONLTWIL6JufXiDA0biY/b8EdOlAc/aW7SfJGCa4zVGVB8ubvSuCFyyqyHeLbrSnXRz9REIy3UJb+CkBFLjEekig4rQd9I3QMm8QJMPTSF3m54JqGIFAZ3dlj+A46W+MY0WtWLNAEII3ysw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LJC3k9WliAr73zaa4gdqjWKL07166ohLBj/H5SauDhb8F2LJtFDmmrLOOF9uBm/EqqnUs3eQ+/u5G+XbK19rtU6D4N3sF27eCt+VGRHYveymgNRYw+fHNHAHJK+lCVU/px5d35VC9BxADJwj6wFNNLru+i3/sEdHSStp8o4aJDtVi9ZoyE2Bzv42lKFrrQQt5jyT+Si5m3mzeChGhyZv3QjupnMv9EVWoVJLSFUVbh5wcAD8RwCL1k18b9VnxRgIApp27SN0hM3kleUEa4D8y8oI520RlTkbfSirI8Rpfd7VgjQ80XxGmZ1MS3MrTL2tU/bI4zPcsMfDbPg8TUQ/xw==
  • Authentication-results: oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 27 Oct 2020 07:37:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWp5gCAaSbdhOl50Ol8t4K8ZvWE6mrGNoA
  • Thread-topic: [bug report] ALSA: xen-front: Use Xen common shared buffer implementation

Hello, Dan!

On 10/21/20 1:50 PM, Dan Carpenter wrote:
> Hello Oleksandr Andrushchenko,
>
> The patch 58f9d806d16a: "ALSA: xen-front: Use Xen common shared
> buffer implementation" from Nov 30, 2018, leads to the following
> static checker warning:
>
>      sound/xen/xen_snd_front_alsa.c:495 alsa_hw_params()
>      warn: 'stream->shbuf.directory' double freed
>      sound/xen/xen_snd_front_alsa.c:495 alsa_hw_params()
>      warn: 'stream->shbuf.grefs' double freed
>
> sound/xen/xen_snd_front_alsa.c
>     461  static int alsa_hw_params(struct snd_pcm_substream *substream,
>     462                            struct snd_pcm_hw_params *params)
>     463  {
>     464          struct xen_snd_front_pcm_stream_info *stream = 
> stream_get(substream);
>     465          struct xen_snd_front_info *front_info = stream->front_info;
>     466          struct xen_front_pgdir_shbuf_cfg buf_cfg;
>     467          int ret;
>     468
>     469          /*
>     470           * This callback may be called multiple times,
>     471           * so free the previously allocated shared buffer if any.
>     472           */
>     473          stream_free(stream);
>                  ^^^^^^^^^^^^^^^^^^^
> This is freed here.
>
>     474          ret = shbuf_setup_backstore(stream, 
> params_buffer_bytes(params));
>     475          if (ret < 0)
>     476                  goto fail;
>                          ^^^^^^^^^^
> This leads to some double frees.  Probably more double frees than Smatch
> is detecting.
>
>     477
>     478          memset(&buf_cfg, 0, sizeof(buf_cfg));
>     479          buf_cfg.xb_dev = front_info->xb_dev;
>     480          buf_cfg.pgdir = &stream->shbuf;
>     481          buf_cfg.num_pages = stream->num_pages;
>     482          buf_cfg.pages = stream->pages;
>     483
>     484          ret = xen_front_pgdir_shbuf_alloc(&buf_cfg);
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is where "stream->shbuf.directory" is re-allocated on the success
> path.
>
>     485          if (ret < 0)
>     486                  goto fail;
>     487
>     488          ret = xen_front_pgdir_shbuf_map(&stream->shbuf);
>     489          if (ret < 0)
>     490                  goto fail;
>     491
>     492          return 0;
>     493
>     494  fail:
>     495          stream_free(stream);
>                  ^^^^^^^^^^^^^^^^^^^^
> Double free.
>
>     496          dev_err(&front_info->xb_dev->dev,
>     497                  "Failed to allocate buffers for stream with index 
> %d\n",
>     498                  stream->index);
>     499          return ret;
>     500  }
>
> regards,
> dan carpenter

Thank you for reporting this,

I'll try to look at it closely and prepare a patch.

Thank you,

Oleksandr

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.