From: Greg KH <gregkh@linuxfoundation.org>
To: Vihas Mak <makvihas@gmail.com>
Cc: sudipm.mukherjee@gmail.com, arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] char: ppdev: fixed a validation issue
Date: Tue, 9 Nov 2021 07:25:36 +0100 [thread overview]
Message-ID: <YYoUYOyyP4EFYTSJ@kroah.com> (raw)
In-Reply-To: <20211108185818.GA73382@makvihas>
On Tue, Nov 09, 2021 at 12:28:18AM +0530, Vihas Mak wrote:
> Make sure the mode is a valid IEEE1284 mode.
What is a valid mode?
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
> drivers/char/ppdev.c | 28 +++++++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
> index 38b46c7d1737..3b290cbf6c66 100644
> --- a/drivers/char/ppdev.c
> +++ b/drivers/char/ppdev.c
> @@ -333,6 +333,28 @@ static enum ieee1284_phase init_phase(int mode)
> return IEEE1284_PH_FWD_IDLE;
> }
>
> +/*
> + * Validate the mode and make sure the mode is power of two.
> + *
> + * IEEE1284_MODE_ECPRLE and IEEE1284_MODE_NIBBLE are exception
> + * to this so handle them accordingly.
> + */
> +
Why the extra line?
> +static int pp_validate_mode(int mode)
bool?
> +{
> + if (mode == IEEE1284_MODE_ECPRLE || mode == IEEE1284_MODE_NIBBLE) {
> + return 1;
> + } else if (!(mode & (mode - 1)) &&
> + (mode & (IEEE1284_MODE_BYTE | IEEE1284_MODE_COMPAT |
> + IEEE1284_MODE_BECP | IEEE1284_MODE_ECP |
> + IEEE1284_MODE_ECPSWE | IEEE1284_MODE_EPP |
> + IEEE1284_MODE_EPPSL | IEEE1284_MODE_COMPAT |
> + IEEE1284_MODE_EPPSWE))) {
> + return 1;
> + }
> + return 0;
> +}
How did you test this? And why is this needed now? What hardware was
working that is now not going to work with this driver?
thanks,
greg k-h
next prev parent reply other threads:[~2021-11-09 6:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 18:58 [PATCH] char: ppdev: fixed a validation issue Vihas Mak
2021-11-09 6:25 ` Greg KH [this message]
2021-11-09 10:41 ` Vihas Mak
2021-11-09 11:23 ` Greg KH
2021-11-09 15:34 ` Vihas Mak
2021-11-09 15:41 ` Greg KH
2021-11-09 17:51 ` Vihas Mak
2021-11-09 17:55 ` Greg KH
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=YYoUYOyyP4EFYTSJ@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=makvihas@gmail.com \
--cc=sudipm.mukherjee@gmail.com \
/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