Skip to contentSkip to conversation

xen: check return value of xenbus_printf

PATCH In review Insu Yun 3 participants 3 messages Oct 15, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 xen: check return value of xenbus_printf

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.

---
 drivers/input/misc/xen-kbdfront.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/input/misc/xen-kbdfront.c +5 -2
index 23d0549..a3b0940 100644
@@ -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();
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · 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.

[...]

drivers/input/misc/xen-kbdfront.c static int xenkbd_probe(struct xenbus_device *dev, · line 135

Quoted 12 lines
drivers/input/misc/xen-kbdfront.c +4 -2
@@ -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

A message that is not in the archive (sent off-list or not yet received): CAGoFzNeiu0sNXUh_JtGp8_HWA+k5xq9s-D4qFqU43Vgm=bYiiA@mail.gmail.com

#3 lore raw

Hi Insu,

Quoted 30 lines · Insu Yun

On Thu, Oct 15, 2015 at 12:40 PM, David Vrabel <[email protected] <mailto:[email protected]>> 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.

Quoted 5 lines

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,

Signature · 1 line
Julien Grall