From patchwork Tue Jan 24 10:26:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9535183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D8EA60434 for ; Tue, 24 Jan 2017 13:36:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AD3427F94 for ; Tue, 24 Jan 2017 13:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F60D27FBC; Tue, 24 Jan 2017 13:36:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9960527F94 for ; Tue, 24 Jan 2017 13:36:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id ED70B266D22; Tue, 24 Jan 2017 14:36:15 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 29775266B93; Tue, 24 Jan 2017 14:33:57 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CAE5426691A; Tue, 24 Jan 2017 11:26:21 +0100 (CET) Received: from mout.web.de (mout.web.de [212.227.17.12]) by alsa0.perex.cz (Postfix) with ESMTP id 34CE9266917 for ; Tue, 24 Jan 2017 11:26:19 +0100 (CET) Received: from [192.168.1.2] ([77.181.182.246]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Md4pC-1cn5Rr1m2E-00ICwq; Tue, 24 Jan 2017 11:26:17 +0100 To: alsa-devel@alsa-project.org, Clemens Ladisch , Jaroslav Kysela , Martin Koegler , Takashi Iwai , Takashi Sakamoto References: From: SF Markus Elfring Message-ID: Date: Tue, 24 Jan 2017 11:26:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:6Fnk5Nq+OCM0TGzwBaOvDMGHiI6+tnIFwGUDEHf9TpJzUy4MAQr 9WpuoSiODB2B4W21QD9H7KDprM0+o1t7ibxww++ha1L1RJjWDfuuky9YJQ0Hdu1nPN/emro 87yKI/6OJkxZdBGL8unxnnHBvt4785o3YtdxvgyTtplDckYmoVsDkSadgGreaXYzNMF7a6W EPzHSJt85ojCokpEbVjxw== X-UI-Out-Filterresults: notjunk:1; V01:K0:FUGS+EYTG2I=:3Ok8oxT/D+c+JDRlIkZ5ua GEM08d4fdyLlkiHcyyXEHxqoDSgPMVU3oZsF58Qyqh5zCxkE0ZEy8jCgj4rv9Ik5UtydQ9SZ0 SfDUynYCWBJbnyc8hXjqGwkmPGfKEmtAy6UDxxGKLYD8EQCNLys/IM1c72fSQGicaS8+AJ3Dy DmImTNcNhEQ3Ch1oFuf62w5DYop9Sduqop//ffH/yisYT/wxwaTBbeI22G1kwT7FuEj/RGTAR khv9jpwfx8ciwsq+0uKnMlkOrNVp+nZfztwA41egzWfLPZN2EB60K5PpUxKHG/s43Y3mr7aRJ XfrSEaZopuGnx9B+HCN56fy6k56DayfzKK6QOFRjuNhTbbxFihna51IbMFr0lsiifN2H5YfAi 26Q5G3GXHKl5pizLWS+HB+DTH1YMLEHfVJgE6iGwenYo1HeDvUWIp2PO5yAH3W5FH/gIqk4fx rqaT8ZACXmcma5wUyEtcdZ2qv9NHIlVDLE86yWWWGy5FYCdsFAX8xNFkTrfv+VoSRF0Ysf6CD kS7kczABRYUbs+taehdy/vV/UAjnRk85zGjRr3d+UfJ9cPYwk8+fubALFkkWNFSp6uAoluO4S +Z9U7Mu08TVkaINYmd2f57vgyuzBbKAIE9LgnQs10EeugbKxLGdteubsGbzrZmunT0sb5UJLQ 49+qF6Q8hm3sHks1z3EI8QMCuWB0I4ew2ErmMBNBJ8d8mxZrrbyBUbgakvq07JfZVqX0XZa8Y DxezszktF8nMkg5W1/7wPzBHlNZLSeXsePVrNtF367i9ZX/A3U1Vfal7My1JzN3UjCmlPnXeF /ML+jpa Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_open() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Tue, 24 Jan 2017 10:05:29 +0100 A local variable was set to an error code in two cases before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a software failure there. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- sound/oss/dmasound/dmasound_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index f4ee85a4c42f..2bdd1d619a7f 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c @@ -1269,13 +1269,15 @@ static int state_open(struct inode *inode, struct file *file) int ret; mutex_lock(&dmasound_core_mutex); - ret = -EBUSY; - if (state.busy) + if (state.busy) { + ret = -EBUSY; goto out; + } - ret = -ENODEV; - if (!try_module_get(dmasound.mach.owner)) + if (!try_module_get(dmasound.mach.owner)) { + ret = -ENODEV; goto out; + } state.ptr = 0; state.busy = 1;