From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44FCAC54EBD for ; Sat, 7 Jan 2023 04:31:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 37494151EF; Sat, 7 Jan 2023 05:30:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 37494151EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673065904; bh=p5QjLRVcqLL4issKK0eLFaIS1pU4BkDK8lzrJ7vzyFQ=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=niHZ6YfkSVx+qwhbyfdP9OKeYZ/Vz0j3IDy2rIcpu1YC6C0MybJeQcZ9m8SI3PNdB foOhCY6EborA+mloW1nx4rBwzwYAyHSwVnE3qofDhTooAGvY8VErM6eeeFbwS0hPtj tPVO7N8hFl5J8MGQItCyIW6+AX+NLfPZaWaar0jg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E075BF804AA; Sat, 7 Jan 2023 05:30:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1323F804AD; Sat, 7 Jan 2023 05:30:52 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BBEF6F80245 for ; Sat, 7 Jan 2023 05:30:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BBEF6F80245 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm2 header.b=E6gX5+h7; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=pzWxDTu2 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 8487C3200916; Fri, 6 Jan 2023 23:30:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 06 Jan 2023 23:30:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1673065839; x=1673152239; bh=e1 6dW3v9va9PCzlypHsh4L0wyzJgWDrrh2QWFdKbXYA=; b=E6gX5+h7twC8uHAHzm KdCeEBauaNmDhHwoBJmGAKi3QFLnYGP6xvrGYlmw+RJyNqhgXL5dtjlD4YquRnUQ SIik4Wp7eLDVttQK5mxPp6wfMvUTZAJj6WKHjjR8FDPSmb2W7addaKtUbwAAmZc5 SxumjasFRqf64NQzZTv4pdwqj91h+1Aa54fOIZMrfJ7ubr215ldjmTrFLUwqe/CL Sows+jLXJGaBtbQdgL3qQKEUvnOuu4rUDs1zM9nA2D6YMfs9S+xpip/Q12XPUm6m IcjUyCVfMiVfcNCtxxmvfO027NEQMrvflGRSAl9QOSsnE3w6UreyhHDauo0D4za0 ezFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1673065839; x=1673152239; bh=e16dW3v9va9PCzlypHsh4L0wyzJg WDrrh2QWFdKbXYA=; b=pzWxDTu2i0TrjBOCQx2sAoqFUZEsuy1JKkwVvTxN/sC9 g2cNufgvpVw1ljb/66OqkSuPl1JfWICgDLYXXX0ztBi/6UEg+4Bv+vZ2rAIfPH6Y Ymg0n/O8WtOPQf0p1nHIjqGV/H5fzchkKJV7PqSOBhJkP49KTvzzkJxlXjNDjIbm 4bXDYXNiNEe8Mu+yVnAfRUE3UHvcbnKdCiy5to+CNuSTXP+Sh0utOK2X1sfp8vtj RNBe6r27mILbTsBRymvM9E/yufTiUP5+isjSeI/L2fHHPjC/WYA/KxW2ZYtyH9I3 /wthsYv0zwxe6QnBWxQ7AvIY9P2GyBoL5Df1rtfcAQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrkedugdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhephefhhfette fgkedvieeuffevveeufedtlefhjeeiieetvdelfedtgfefuedukeeunecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 Jan 2023 23:30:37 -0500 (EST) Date: Sat, 7 Jan 2023 13:30:35 +0900 From: Takashi Sakamoto To: Dan Carpenter Subject: Re: [bug report] ALSA: firewire-motu: notify event for parameter change in register DSP model Message-ID: Mail-Followup-To: Dan Carpenter , alsa-devel@alsa-project.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, On Fri, Jan 06, 2023 at 12:31:12PM +0300, Dan Carpenter wrote: > Hello Takashi Sakamoto, > > The patch 634ec0b2906e: "ALSA: firewire-motu: notify event for > parameter change in register DSP model" from Oct 15, 2021, leads to > the following Smatch static checker warning: > > sound/firewire/motu/motu-hwdep.c:92 hwdep_read() > warn: inconsistent returns '&motu->lock'. Indeed. When no event is available, the bug appears. Later, I'll post quick fix. Thanks. > sound/firewire/motu/motu-hwdep.c > 27 static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, > 28 loff_t *offset) > 29 { > 30 struct snd_motu *motu = hwdep->private_data; > 31 DEFINE_WAIT(wait); > 32 union snd_firewire_event event; > 33 > 34 spin_lock_irq(&motu->lock); > 35 > 36 while (!motu->dev_lock_changed && motu->msg == 0 && !has_dsp_event(motu)) { > 37 prepare_to_wait(&motu->hwdep_wait, &wait, TASK_INTERRUPTIBLE); > 38 spin_unlock_irq(&motu->lock); > 39 schedule(); > 40 finish_wait(&motu->hwdep_wait, &wait); > 41 if (signal_pending(current)) > 42 return -ERESTARTSYS; > 43 spin_lock_irq(&motu->lock); > 44 } > 45 > 46 memset(&event, 0, sizeof(event)); > 47 if (motu->dev_lock_changed) { > 48 event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; > 49 event.lock_status.status = (motu->dev_lock_count > 0); > 50 motu->dev_lock_changed = false; > 51 spin_unlock_irq(&motu->lock); > 52 > 53 count = min_t(long, count, sizeof(event)); > 54 if (copy_to_user(buf, &event, count)) > 55 return -EFAULT; > 56 } else if (motu->msg > 0) { > 57 event.motu_notification.type = SNDRV_FIREWIRE_EVENT_MOTU_NOTIFICATION; > 58 event.motu_notification.message = motu->msg; > 59 motu->msg = 0; > 60 spin_unlock_irq(&motu->lock); > 61 > 62 count = min_t(long, count, sizeof(event)); > 63 if (copy_to_user(buf, &event, count)) > 64 return -EFAULT; > 65 } else if (has_dsp_event(motu)) { > 66 size_t consumed = 0; > 67 u32 __user *ptr; > 68 u32 ev; > 69 > 70 spin_unlock_irq(&motu->lock); > 71 > 72 // Header is filled later. > 73 consumed += sizeof(event.motu_register_dsp_change); > 74 > 75 while (consumed < count && > 76 snd_motu_register_dsp_message_parser_copy_event(motu, &ev)) { > 77 ptr = (u32 __user *)(buf + consumed); > 78 if (put_user(ev, ptr)) > 79 return -EFAULT; > 80 consumed += sizeof(ev); > 81 } > 82 > 83 event.motu_register_dsp_change.type = SNDRV_FIREWIRE_EVENT_MOTU_REGISTER_DSP_CHANGE; > 84 event.motu_register_dsp_change.count = > 85 (consumed - sizeof(event.motu_register_dsp_change)) / 4; > 86 if (copy_to_user(buf, &event, sizeof(event.motu_register_dsp_change))) > 87 return -EFAULT; > 88 > 89 count = consumed; > 90 } > > Smatch complains that there is no "} else {" path which unlocks. > > > 91 > --> 92 return count; > 93 } > > regards, > dan carpenter Takashi Sakamoto