From nobody Fri Nov 29 14:32:02 2024 Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 863B33D76; Wed, 18 Sep 2024 18:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726684368; cv=none; b=fPRY+AdHL/ULjGi5F/jTDZUVpnTJSA5C9eVO8gNOhskvVcFp+DbG7+HOXJKvkKfgvJpQ+HuNaqYSsOwg70bSfnPyB7xeYJZ9D2ugjn6g7WQJurnlyytHnxSGYCdMNYXF8xxi8DE6xWWpct02PwxkjADxjbhwN+6NbPmjYkpudKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726684368; c=relaxed/simple; bh=YJkeuTsxBPiyvTUP/blR4RkykjAI4i8ZteKtKxrLGL4=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=GwJffbmur15BzEV5+uYUiLDTjje70JTGOGJWos1oz1gvCPOrAPgkmdS/qSGaWTiwI3NZnj2HXr9HaBKR4epbEkt5azDDwy+RmZRCxLJNj4nein4qTfRaxvrrGYrRQrZNGXXXw7YQ2Y3uArXoTJt8OxtqrT/aE6l47ZsTSrezL9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=nqOveIaX; arc=none smtp.client-ip=212.227.15.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="nqOveIaX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1726684348; x=1727289148; i=markus.elfring@web.de; bh=O9DaIs4hHxakPCjTXFbcAKjoZvONlDT+AZcVxmGqFGM=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:From: Subject:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=nqOveIaXitWWy/I6XyvWDpfx/cQ5x0BeLn/Jh5wbt4ChBKTTjPl4JxrQJ7m4lpwN 8pYFSyAZuN6RsZ3uFjUt6SxkVbZ9CF8CA9jYf8SuKvQMX2bMZjuzEc4vazzraGaBp LLAvxJ+7VkVcsldA3gHOo4XPsZPt8nGOYuC1+0mztIL+JZIUkeVkNveO2B9GL/Yt0 fbaqTmzA+5EPKT5Ft+fuCQXJfg9Mh/QGLu/ZJ5l+syfn7WhQNu9FUnGuUMKNNvDfL GSpEWHn2wtdZoGjRTNAONxcZ7GOGvTUxJulMSE4E1bVrhY13ldcf0tTBpAheUWthF s61m0K0bGTLmQ3E9WQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MdwNW-1sITfh34y6-00q8iX; Wed, 18 Sep 2024 20:32:28 +0200 Message-ID: <089721e7-367a-477d-a4b7-a712244bb5d3@web.de> Date: Wed, 18 Sep 2024 20:32:26 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: kernel-janitors@vger.kernel.org, Arnd Bergmann , Christian Brauner , Greg Kroah-Hartman , Jeff Layton Content-Language: en-GB Cc: LKML From: Markus Elfring Subject: [PATCH] ibmasmfs: Use common error handling code in command_file_read() Content-Transfer-Encoding: quoted-printable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Q1WzTcSO7AdZVliaKNtKSNvqN77yQ35Htlr3AXZS mw2He5C5iCWs2Gmi9KU9nr8g== Content-Type: text/plain; charset="utf-8" From: Markus Elfring Date: Wed, 18 Sep 2024 19:50:27 +0200 Add a label so that a bit of exception handling can be better reused at the end of this function implementation. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/misc/ibmasm/ibmasmfs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index c44de892a61e..93b69f473452 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -280,14 +280,15 @@ static ssize_t command_file_read(struct file *file, c= har __user *buf, size_t cou spin_unlock_irqrestore(&command_data->sp->lock, flags); if (cmd->status !=3D IBMASM_CMD_COMPLETE) { - command_put(cmd); - return -EIO; + len =3D -EIO; + goto put_command; } len =3D min(count, cmd->buffer_size); if (copy_to_user(buf, cmd->buffer, len)) { - command_put(cmd); - return -EFAULT; + len =3D -EFAULT; + goto put_command; } +put_command: command_put(cmd); return len; -- 2.46.0