From: Jiri Slaby <jirislaby@kernel.org>
To: George Kennedy <george.kennedy@oracle.com>,
gregkh@linuxfoundation.org, torvalds@linux-foundation.org
Cc: sfr@canb.auug.org.au, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] vc_screen: break from vcs_read() while loop if vcs_vc() returns NULL
Date: Wed, 8 Feb 2023 06:48:11 +0100 [thread overview]
Message-ID: <8dffe187-240d-746e-ed84-885ffd2785f6@kernel.org> (raw)
In-Reply-To: <1675774098-17722-1-git-send-email-george.kennedy@oracle.com>
On 07. 02. 23, 13:48, George Kennedy wrote:
> If vcs_vc() returns NULL in vcs_read(), break from while loop if partial
> read, else if no reads have been done, go to unlock_out and return -ENXIO.
> In addition, change the goto unlock_out after vcs_size() to a break
> to conform to the break handling after vcs_vc().
>
> Fixes: ac751efa6a0d ("console: rename acquire/release_console_sem() to console_lock/unlock()")
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: George Kennedy <george.kennedy@oracle.com>
> ---
> drivers/tty/vt/vc_screen.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
> index f566eb1839dc..c599b452969f 100644
> --- a/drivers/tty/vt/vc_screen.c
> +++ b/drivers/tty/vt/vc_screen.c
> @@ -406,19 +406,17 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> ret = -ENXIO;
> vc = vcs_vc(inode, &viewed);
> if (!vc)
> - goto unlock_out;
> + break;
>
> /* Check whether we are above size each round,
> * as copy_to_user at the end of this loop
> * could sleep.
> */
> - size = vcs_size(vc, attr, uni_mode);
> - if (size < 0) {
> - if (read)
> - break;
> - ret = size;
> - goto unlock_out;
> - }
> + ret = vcs_size(vc, attr, uni_mode);
> + if (ret < 0)
> + break;
> + size = ret;
> + ret = 0;
I think the previous "size = vcs_size()" and "ret = size" in the error
path looked better than this "size = ret" and "ret = 0" here. I mean why
not to preserve:
size = vcs_size(vc, attr, uni_mode);
if (size < 0) {
ret = size;
break;
}
?
thanks,
--
js
suse labs
prev parent reply other threads:[~2023-02-08 5:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 12:48 [PATCH v2] vc_screen: break from vcs_read() while loop if vcs_vc() returns NULL George Kennedy
2023-02-08 5:48 ` Jiri Slaby [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8dffe187-240d-746e-ed84-885ffd2785f6@kernel.org \
--to=jirislaby@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=george.kennedy@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).