Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp297549pxb; Thu, 25 Feb 2021 02:52:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvSVN47s2CcZerNIY8PUAWmyTCHOLdDWfiLVksh6Ka2ySvdOAOFYtIfL08t5XQU5f0qHRO X-Received: by 2002:a17:906:f119:: with SMTP id gv25mr2010138ejb.293.1614250351906; Thu, 25 Feb 2021 02:52:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614250351; cv=none; d=google.com; s=arc-20160816; b=epGGa851d1ogarfHFDb/HhAA1PPmPqx3fs+OHfg1wmkqEmNHJJpwHNVVz2OsUL45LX fSpY78R0gFn4JFCP2MRVpKUkXPrfOhIGHd6I4jdtZ2n2SvAWDXNY5RDjM/QDEwzc8l5s I3TrFFRNJppe3Cu82JumZ3PhFe48T7tMCdPri6i5etkRC61rDckfhDSQa40cgsEG+9Af MZwUBtTsSLAswEUJ7DN4UttohYVfKtVvdQI0Plo9X6ZAMddxxxaHO5Q4ZOnzQjYsBdJ3 nnCxLFoHKlXRTXri9R01zunAADmtsYzKuo1VKpyy3OUijAVzff3bT06qfAcbxlrSJooD xcIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=za3uc7VrEggU5xg4ZvI2RZb8hzG736HhmZv3SLpJfXk=; b=IuxVoGVd3mLciy+beOwLJyHOcLIx4OrJl7qiVDnkQeOw2hwB5m7fkCr2auE+HWh8QM wO4U6XzVNP/OvLEyujggC7kN7pJK72tVsqVv0v0UpyYpiqW09pVI9NiANvMA5z6cf1XC 6qSA2byF3U8WY1McdliLaFcxFlOWNH8/mIvMUvjNu4Sa1GtQIrNUckQY20i/R93rEIrk +lcL0/7GfuZkfd6AXFa5w9rxoDpfjPXIvW6xIrbI49MC5W/m+hmqmqy+zupvlQ5iX1H4 VVBv8Up37pDszLKtQPiNhlEpwpnF7vnJbhsNHPJQR2Ue3YWaawNV1sKhA6ztmjIcniJx x96g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si3005617edy.357.2021.02.25.02.52.09; Thu, 25 Feb 2021 02:52:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbhBYKvS (ORCPT + 99 others); Thu, 25 Feb 2021 05:51:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:40788 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbhBYKjX (ORCPT ); Thu, 25 Feb 2021 05:39:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2AB1FAAAE; Thu, 25 Feb 2021 10:38:36 +0000 (UTC) Date: Thu, 25 Feb 2021 11:38:35 +0100 Message-ID: From: Takashi Iwai To: Anton Yakovlev Cc: , , , "Michael S. Tsirkin" , Jaroslav Kysela , Takashi Iwai , Jason Wang , Subject: Re: [PATCH v5 2/9] ALSA: virtio: add virtio sound driver In-Reply-To: <20210222153444.348390-3-anton.yakovlev@opensynergy.com> References: <20210222153444.348390-1-anton.yakovlev@opensynergy.com> <20210222153444.348390-3-anton.yakovlev@opensynergy.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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