[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <s5h7dmwqvo4.wl-tiwai@suse.de>
Date: Thu, 25 Feb 2021 11:38:35 +0100
From: Takashi Iwai <tiwai@...e.de>
To: Anton Yakovlev <anton.yakovlev@...nsynergy.com>
Cc: <virtualization@...ts.linux-foundation.org>,
<alsa-devel@...a-project.org>, <virtio-dev@...ts.oasis-open.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Jason Wang <jasowang@...hat.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 2/9] ALSA: virtio: add virtio sound driver
On Mon, 22 Feb 2021 16:34:37 +0100,
Anton Yakovlev wrote:
> +static int virtsnd_find_vqs(struct virtio_snd *snd)
> +{
> + struct virtio_device *vdev = snd->vdev;
> + vq_callback_t *callbacks[VIRTIO_SND_VQ_MAX] = {
> + [VIRTIO_SND_VQ_EVENT] = virtsnd_event_notify_cb
> + };
> + const char *names[VIRTIO_SND_VQ_MAX] = {
Shouldn't be static?
Also it's often const char * const names[] = { ... }
unless you overwrite something.
> +/**
> + * virtsnd_reset_fn() - Kernel worker's function to reset the device.
> + * @work: Reset device work.
> + *
> + * Context: Process context.
> + */
> +static void virtsnd_reset_fn(struct work_struct *work)
> +{
> + struct virtio_snd *snd =
> + container_of(work, struct virtio_snd, reset_work);
> + struct virtio_device *vdev = snd->vdev;
> + struct device *dev = &vdev->dev;
> + int rc;
> +
> + dev_info(dev, "sound device needs reset\n");
> +
> + /*
> + * It seems that the only way to properly reset the device is to remove
> + * and re-create the ALSA sound card device.
> + */
> + rc = device_reprobe(dev);
> + if (rc)
> + dev_err(dev, "failed to reprobe sound device: %d\n", rc);
Now I'm wondering whether it's safe to do that from this place.
Basically device_reprobe() unbinds the device that releases the full
resources once including the devm_* stuff. And this work itself is in
a part of devm allocated resource, so it'll be released there. That
said, we might hit use-after-free... This needs to be verified.
thanks,
Takashi
Powered by blists - more mailing lists