[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] libxc: avoid clobbering errno in xc_domain_pod_target()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 10 Dec 2021 14:11:53 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NIgRq885eRJJwq0chVRIWHi4lkmdLRe+pMw/ZXiNwIY=; b=QulPQKC3rC2rqKUf4pzrNCw773CQLstUS9UM0yGc/QLt/U4MHVfoAZSMmYb+pKGXQ5522d/fNKclhoqVgqMIUYaOL90Qa0DWdBlB3sTS11Sopi4UkfHpf7YySGNlyL8F1jCnlYjqIfGXM7tgBP9N8XbHwJw3708Cy9A+6d7x9/vBhX1mtCNVfv+noOY0RsRm6DSZMIQQHb7k/35Z7EypQT3xr6vWitjwYRosNE5kSadTntZ9Tz7KeebkdKgQvHz1JacJqtCG14T4Qz+lIU/HFkQ1oQMTTywcz94dqFtRmeyqThLi49by/jiOD1rj31ZB1PRwK5l/M+LImmDUeNWb6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Au2WrLVUovDiaHq6s75yPHTEWcuTpllDQ6WMRgLObLYEJSdMVIB6aJZzIf06BkPw2/kkv+l48z2X7q3fZglXu1oZdbqGL7g1Ii1xArEFnenS+Km1fqDfo1pIjzE2H3e8zpPG6RlMyrLFXphnCTbRYpNbiEUGjPlpf4KXElWxj6SiEnbSPBGoKQp6U7BtDiJJG0vrJCwi3DbSpAQ7sZaQB/cAPctouZexfSjOn+6731luo4jfzSVoN1TjvH4XpLzrC0GgMs1kEDaLWNu1t4sdzAyiFlUEq2GFc3N11wAauKKuZybdBwzp3qMH5f1Ljxtphf+ClfWLF9gI4rF4kaLJag==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Fri, 10 Dec 2021 13:12:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

do_memory_op() supplies return value and has "errno" set the usual way.
Don't overwrite "errno" with 1 (aka EPERM on at least Linux). There's
also no reason to overwrite "err".

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
While the hypervisor side of the hypercall gives the impression of being
able to return positive values as of 637a283f17eb ("PoD: Allow
pod_set_cache_target hypercall to be preempted"), due to the use of
"rc >= 0" there, afaict that's not actually the case. IOW "err" can
really only be 0 or -1 here, and hence its setting to zero may also be
worthwhile to drop.
---
v2: Don't save/restore errno, as DPRINTF() already does so.

--- a/tools/libs/ctrl/xc_domain.c
+++ b/tools/libs/ctrl/xc_domain.c
@@ -1230,13 +1230,9 @@ static int xc_domain_pod_target(xc_inter
     err = do_memory_op(xch, op, &pod_target, sizeof(pod_target));
 
     if ( err < 0 )
-    {
         DPRINTF("Failed %s_pod_target dom %d\n",
                 (op==XENMEM_set_pod_target)?"set":"get",
                 domid);
-        errno = -err;
-        err = -1;
-    }
     else
         err = 0;
 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.