linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: check return value of xenbus_printf
@ 2015-10-15 16:25 Insu Yun
  2015-10-15 16:40 ` David Vrabel
  0 siblings, 1 reply; 9+ messages in thread
From: Insu Yun @ 2015-10-15 16:25 UTC (permalink / raw)
  To: dmitry.torokhov, david.vrabel, wei.liu2, julien.grall,
	stefano.stabellini, huaixin.chx, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, Insu Yun

Internally, xenbus_printf uses memory allocation, so it can be failed in
memory pressure.Therefore, xenbus_printf's return should be checked 
and properly handled.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/input/misc/xen-kbdfront.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 23d0549..a3b0940 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -129,8 +129,11 @@ static int xenkbd_probe(struct xenbus_device *dev,
 
 	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
 		abs = 0;
-	if (abs)
-		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
+	if (abs) {
+		ret = xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
+		if (ret)
+			pr_warning("xenkbd: can't request abs-pointer");
+  }
 
 	/* keyboard */
 	kbd = input_allocate_device();
-- 
1.9.1


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

* Re: [PATCH] xen: check return value of xenbus_printf
  2015-10-15 16:25 Insu Yun
@ 2015-10-15 16:40 ` David Vrabel
       [not found]   ` <CAGoFzNeiu0sNXUh_JtGp8_HWA+k5xq9s-D4qFqU43Vgm=bYiiA@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: David Vrabel @ 2015-10-15 16:40 UTC (permalink / raw)
  To: Insu Yun, dmitry.torokhov, wei.liu2, julien.grall,
	stefano.stabellini, huaixin.chx, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu

On 15/10/15 17:25, Insu Yun wrote:
> Internally, xenbus_printf uses memory allocation, so it can be failed in
> memory pressure.Therefore, xenbus_printf's return should be checked 
> and properly handled.
[...]
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -129,8 +129,11 @@ static int xenkbd_probe(struct xenbus_device *dev,
>  
>  	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
>  		abs = 0;
> -	if (abs)
> -		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
> +	if (abs) {
> +		ret = xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
> +		if (ret)
> +			pr_warning("xenkbd: can't request abs-pointer");

I think you want abs = 0 here or input device will be configured as
absolute but the backend will supply relative coordinates.

David

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

* Re: [PATCH] xen: check return value of xenbus_printf
       [not found]   ` <CAGoFzNeiu0sNXUh_JtGp8_HWA+k5xq9s-D4qFqU43Vgm=bYiiA@mail.gmail.com>
@ 2015-10-15 18:20     ` Julien Grall
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Grall @ 2015-10-15 18:20 UTC (permalink / raw)
  To: Insu Yun, David Vrabel
  Cc: Dmitry Torokhov, Wei Liu, Stefano Stabellini, huaixin.chx,
	linux-input, linux-kernel, Taesoo Kim, Yeongjin Jang, Yun, Insu

Hi Insu,

On 15/10/15 19:12, Insu Yun wrote:
> 
> 
> On Thu, Oct 15, 2015 at 12:40 PM, David Vrabel <david.vrabel@citrix.com
> <mailto:david.vrabel@citrix.com>> wrote:
> 
>     On 15/10/15 17:25, Insu Yun wrote:
>     > Internally, xenbus_printf uses memory allocation, so it can be failed in
>     > memory pressure.Therefore, xenbus_printf's return should be checked
>     > and properly handled.
>     [...]
>     > --- a/drivers/input/misc/xen-kbdfront.c
>     > +++ b/drivers/input/misc/xen-kbdfront.c
>     > @@ -129,8 +129,11 @@ static int xenkbd_probe(struct xenbus_device *dev,
>     >
>     >       if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
>     >               abs = 0;
>     > -     if (abs)
>     > -             xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
>     > +     if (abs) {
>     > +             ret = xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
>     > +             if (ret)
> 
>     > +                     pr_warning("xenkbd: can't request abs-pointer");
> 
> 
> This error handling is from other code .
> I am not sure that it is right error handling.
>  
> 
> 
>     I think you want abs = 0 here or input device will be configured as
>     absolute but the backend will supply relative coordinates.
> 
> 
> I cannot understand

If the frontend is not able to write the node "request-abs-pointer" in
the xenstore, the backend will always supply relative coordinates.

Although, as abs = 1, the frontend will be configured to handle absolute
coordinate. So the backend and frontend won't be able to understand each
other.

So you have to set abs to 0 if xebus_printf fails.

Regards,

-- 
Julien Grall

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

* [PATCH] xen: check return value of xenbus_printf
@ 2015-10-15 18:40 Insu Yun
  2015-10-16  0:01 ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Insu Yun @ 2015-10-15 18:40 UTC (permalink / raw)
  To: dmitry.torokhov, david.vrabel, wei.liu2, julien.grall,
	stefano.stabellini, huaixin.chx, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, Insu Yun

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 23d0549..9d465d7 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
 
 	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
 		abs = 0;
-	if (abs)
-		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
+	if (abs) {
+		ret = xenbus_printf(XBT_NIL, dev->nodename,
+					"request-abs-pointer", "1");
+		if (ret) {
+			pr_warning("xenkbd: can't request abs-pointer");
+			abs = 0;
+		}
+	}
 
 	/* keyboard */
 	kbd = input_allocate_device();
-- 
1.9.1


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

* Re: [PATCH] xen: check return value of xenbus_printf
  2015-10-15 18:40 Insu Yun
@ 2015-10-16  0:01 ` Dmitry Torokhov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2015-10-16  0:01 UTC (permalink / raw)
  To: Insu Yun
  Cc: david.vrabel, wei.liu2, julien.grall, stefano.stabellini,
	huaixin.chx, linux-input, linux-kernel, taesoo, yeongjin.jang,
	insu

Hi Insu,

On Thu, Oct 15, 2015 at 06:40:12PM +0000, Insu Yun wrote:
> Signed-off-by: Insu Yun <wuninsu@gmail.com>

It looks lik eyou lost your patch description when respinning.

Thanks.

> ---
>  drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
> index 23d0549..9d465d7 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
>  
>  	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
>  		abs = 0;
> -	if (abs)
> -		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
> +	if (abs) {
> +		ret = xenbus_printf(XBT_NIL, dev->nodename,
> +					"request-abs-pointer", "1");
> +		if (ret) {
> +			pr_warning("xenkbd: can't request abs-pointer");
> +			abs = 0;
> +		}
> +	}
>  
>  	/* keyboard */
>  	kbd = input_allocate_device();
> -- 
> 1.9.1
> 

-- 
Dmitry

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

* [PATCH] xen: check return value of xenbus_printf
@ 2015-10-19 14:10 Insu Yun
  2015-10-19 14:30 ` Julien Grall
  0 siblings, 1 reply; 9+ messages in thread
From: Insu Yun @ 2015-10-19 14:10 UTC (permalink / raw)
  To: dmitry.torokhov, stefano.stabellini, david.vrabel, wei.liu2,
	julien.grall, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

Internally, xenbus_printf uses memory allocation, so it can be failed in
memory pressure.Therefore, xenbus_printf's return should be checked
and properly handled.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 23d0549..9d465d7 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
 
 	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
 		abs = 0;
-	if (abs)
-		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
+	if (abs) {
+		ret = xenbus_printf(XBT_NIL, dev->nodename,
+					"request-abs-pointer", "1");
+		if (ret) {
+			pr_warning("xenkbd: can't request abs-pointer");
+			abs = 0;
+		}
+	}
 
 	/* keyboard */
 	kbd = input_allocate_device();
-- 
1.9.1

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

* Re: [PATCH] xen: check return value of xenbus_printf
  2015-10-19 14:10 [PATCH] xen: check return value of xenbus_printf Insu Yun
@ 2015-10-19 14:30 ` Julien Grall
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Grall @ 2015-10-19 14:30 UTC (permalink / raw)
  To: Insu Yun, dmitry.torokhov, stefano.stabellini, david.vrabel,
	wei.liu2, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo

Hi,

On 19/10/15 15:10, Insu Yun wrote:
> Internally, xenbus_printf uses memory allocation, so it can be failed in
> memory pressure.Therefore, xenbus_printf's return should be checked
> and properly handled.
> 
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
> ---
>  drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
> index 23d0549..9d465d7 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
>  
>  	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
>  		abs = 0;
> -	if (abs)
> -		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
> +	if (abs) {
> +		ret = xenbus_printf(XBT_NIL, dev->nodename,
> +					"request-abs-pointer", "1");

The second line of arguments should be aligned to the first parameter. I.e:

xenbus_printf(XBT_NIL, dev->nodename,
              "request-abs-pointer", "1");

See an example in xenkbd_backend_changed.

With that fixed:

Reviewed-by: Julien Grall <julien.grall@citrix.com>

> +		if (ret) {
> +			pr_warning("xenkbd: can't request abs-pointer");

Note that checkpatch.pl will print a warning here:

WARNING: Prefer pr_warn(... to pr_warning(...
#27: FILE: drivers/input/misc/xen-kbdfront.c:136:
+                       pr_warning("xenkbd: can't request abs-pointer");


Although, I'm fine if you don't fix this one.

> +			abs = 0;
> +		}
> +	}
>  
>  	/* keyboard */
>  	kbd = input_allocate_device();
> 

Regards,

-- 
Julien Grall

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

* [PATCH] xen: check return value of xenbus_printf
@ 2015-10-19 16:02 Insu Yun
  2015-10-19 16:46 ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Insu Yun @ 2015-10-19 16:02 UTC (permalink / raw)
  To: dmitry.torokhov, wei.liu2, david.vrabel, stefano.stabellini,
	julien.grall, linux-input, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 23d0549..0a9ad2cf 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
 
 	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
 		abs = 0;
-	if (abs)
-		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
+	if (abs) {
+		ret = xenbus_printf(XBT_NIL, dev->nodename,
+				    "request-abs-pointer", "1");
+		if (ret) {
+			pr_warning("xenkbd: can't request abs-pointer");
+			abs = 0;
+		}
+	}
 
 	/* keyboard */
 	kbd = input_allocate_device();
-- 
1.9.1


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

* Re: [PATCH] xen: check return value of xenbus_printf
  2015-10-19 16:02 Insu Yun
@ 2015-10-19 16:46 ` Dmitry Torokhov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2015-10-19 16:46 UTC (permalink / raw)
  To: Insu Yun
  Cc: wei.liu2, david.vrabel, stefano.stabellini, julien.grall,
	linux-input, linux-kernel, taesoo, yeongjin.jang, insu, changwoo

On Mon, Oct 19, 2015 at 04:02:51PM +0000, Insu Yun wrote:
> Signed-off-by: Insu Yun <wuninsu@gmail.com>

Applied, thank you. However you still are missing the commit description
on this version of the patch; I had to fish it from your original
posting.

Thanks.

> ---
>  drivers/input/misc/xen-kbdfront.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
> index 23d0549..0a9ad2cf 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -129,8 +129,14 @@ static int xenkbd_probe(struct xenbus_device *dev,
>  
>  	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
>  		abs = 0;
> -	if (abs)
> -		xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
> +	if (abs) {
> +		ret = xenbus_printf(XBT_NIL, dev->nodename,
> +				    "request-abs-pointer", "1");
> +		if (ret) {
> +			pr_warning("xenkbd: can't request abs-pointer");
> +			abs = 0;
> +		}
> +	}
>  
>  	/* keyboard */
>  	kbd = input_allocate_device();
> -- 
> 1.9.1
> 

-- 
Dmitry

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

end of thread, other threads:[~2015-10-19 16:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 14:10 [PATCH] xen: check return value of xenbus_printf Insu Yun
2015-10-19 14:30 ` Julien Grall
  -- strict thread matches above, loose matches on Subject: below --
2015-10-19 16:02 Insu Yun
2015-10-19 16:46 ` Dmitry Torokhov
2015-10-15 18:40 Insu Yun
2015-10-16  0:01 ` Dmitry Torokhov
2015-10-15 16:25 Insu Yun
2015-10-15 16:40 ` David Vrabel
     [not found]   ` <CAGoFzNeiu0sNXUh_JtGp8_HWA+k5xq9s-D4qFqU43Vgm=bYiiA@mail.gmail.com>
2015-10-15 18:20     ` Julien Grall

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