linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: moxtet: Update proper type 'size_t' to 'ssize_t'
@ 2019-09-11  5:59 Austin Kim
  2019-09-11 13:12 ` Marek Behun
  0 siblings, 1 reply; 3+ messages in thread
From: Austin Kim @ 2019-09-11  5:59 UTC (permalink / raw)
  To: marek.behun; +Cc: linux-kernel, austindh.kim

The simple_write_to_buffer() returns ssize_t type value,
which is either positive or negative.

However 'res' is declared as size_t(unsigned int)
which contains non-negative type.

So 'res < 0' statement is always false,
this cannot execute execptional-case  handling.

To prevent this case,
update proper type 'size_t' to 'ssize_t' for execptional handling.

Signed-off-by: Austin Kim <austindh.kim@gmail.com>
---
 drivers/bus/moxtet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/moxtet.c b/drivers/bus/moxtet.c
index 1ee4570..288a9e4 100644
--- a/drivers/bus/moxtet.c
+++ b/drivers/bus/moxtet.c
@@ -514,7 +514,7 @@ static ssize_t output_write(struct file *file, const char __user *buf,
 	struct moxtet *moxtet = file->private_data;
 	u8 bin[TURRIS_MOX_MAX_MODULES];
 	u8 hex[sizeof(bin) * 2 + 1];
-	size_t res;
+	ssize_t res;
 	loff_t dummy = 0;
 	int err, i;
 
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bus: moxtet: Update proper type 'size_t' to 'ssize_t'
  2019-09-11  5:59 [PATCH] bus: moxtet: Update proper type 'size_t' to 'ssize_t' Austin Kim
@ 2019-09-11 13:12 ` Marek Behun
  2019-09-11 13:48   ` Austin Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Behun @ 2019-09-11 13:12 UTC (permalink / raw)
  To: Austin Kim; +Cc: linux-kernel

Hi Austin,
this was already fixed and is staged for soc/for-next, see
https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git/commit/?h=for-next&id=6811d26df50d96635dd339cf8cdf43a6abc0c4b6

Thanks,
Marek

On Wed, 11 Sep 2019 14:59:38 +0900
Austin Kim <austindh.kim@gmail.com> wrote:

> The simple_write_to_buffer() returns ssize_t type value,
> which is either positive or negative.
> 
> However 'res' is declared as size_t(unsigned int)
> which contains non-negative type.
> 
> So 'res < 0' statement is always false,
> this cannot execute execptional-case  handling.
> 
> To prevent this case,
> update proper type 'size_t' to 'ssize_t' for execptional handling.
> 
> Signed-off-by: Austin Kim <austindh.kim@gmail.com>
> ---
>  drivers/bus/moxtet.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/moxtet.c b/drivers/bus/moxtet.c
> index 1ee4570..288a9e4 100644
> --- a/drivers/bus/moxtet.c
> +++ b/drivers/bus/moxtet.c
> @@ -514,7 +514,7 @@ static ssize_t output_write(struct file *file, const char __user *buf,
>  	struct moxtet *moxtet = file->private_data;
>  	u8 bin[TURRIS_MOX_MAX_MODULES];
>  	u8 hex[sizeof(bin) * 2 + 1];
> -	size_t res;
> +	ssize_t res;
>  	loff_t dummy = 0;
>  	int err, i;
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bus: moxtet: Update proper type 'size_t' to 'ssize_t'
  2019-09-11 13:12 ` Marek Behun
@ 2019-09-11 13:48   ` Austin Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Austin Kim @ 2019-09-11 13:48 UTC (permalink / raw)
  To: Marek Behun; +Cc: linux-kernel

Good!
Thanks for notification.

2019년 9월 11일 (수) 오후 10:12, Marek Behun <marek.behun@nic.cz>님이 작성:
>
> Hi Austin,
> this was already fixed and is staged for soc/for-next, see
> https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git/commit/?h=for-next&id=6811d26df50d96635dd339cf8cdf43a6abc0c4b6
>
> Thanks,
> Marek
>
> On Wed, 11 Sep 2019 14:59:38 +0900
> Austin Kim <austindh.kim@gmail.com> wrote:
>
> > The simple_write_to_buffer() returns ssize_t type value,
> > which is either positive or negative.
> >
> > However 'res' is declared as size_t(unsigned int)
> > which contains non-negative type.
> >
> > So 'res < 0' statement is always false,
> > this cannot execute execptional-case  handling.
> >
> > To prevent this case,
> > update proper type 'size_t' to 'ssize_t' for execptional handling.
> >
> > Signed-off-by: Austin Kim <austindh.kim@gmail.com>
> > ---
> >  drivers/bus/moxtet.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/bus/moxtet.c b/drivers/bus/moxtet.c
> > index 1ee4570..288a9e4 100644
> > --- a/drivers/bus/moxtet.c
> > +++ b/drivers/bus/moxtet.c
> > @@ -514,7 +514,7 @@ static ssize_t output_write(struct file *file, const char __user *buf,
> >       struct moxtet *moxtet = file->private_data;
> >       u8 bin[TURRIS_MOX_MAX_MODULES];
> >       u8 hex[sizeof(bin) * 2 + 1];
> > -     size_t res;
> > +     ssize_t res;
> >       loff_t dummy = 0;
> >       int err, i;
> >
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-11 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  5:59 [PATCH] bus: moxtet: Update proper type 'size_t' to 'ssize_t' Austin Kim
2019-09-11 13:12 ` Marek Behun
2019-09-11 13:48   ` Austin Kim

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).