Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4840183imm; Mon, 11 Jun 2018 20:52:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKkCTRsaXArn1gT0bnGQwr6R50Kg3g+nPPQnnP3r+uKs99qkglrB7UU8XAPZowkBHD7jDf9 X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2048870plb.255.1528775546867; Mon, 11 Jun 2018 20:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528775546; cv=none; d=google.com; s=arc-20160816; b=tsiRVhvwlczDbFXVOCza5yP9SvEKb0re7/H5oe8rsGBDk86Lakbj1FX2AjA/XUO5bO DcDnO9To0ww21i7oX6wQQBrAcrbEIO7LMmLdlpZJBegBGd6BHZiNrHn5BQ8MDuJ908d7 Zf0t0bQ6OUsh6VESOTXSq7zpoyCnS509ofevrJlE5OQwtq3GNdEgclZsEm3357l21rQp xb0BgQ0lwk/1cl7Stvvk8V8x09yH7vRSfBNnNLl1kZSi6/IMeZhQCzOCBBQk47zMh2CV D5pULsgoPWp0Equ0ZQY/oUA5Mpr1/7Pjk5DRKlH7g6sYJ/Bh8cdlfX207nDz/38nrDoU zFLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=aUhT9jqKZFY72Z1/qW6kXOFlp/YvK0MiyVB6Pgj0070=; b=BjkE7NG/PyWSJcIHMc+/EzQ4YImUc35Ao+vnlP3+Ws1NOFCjpXX1U87E5W2KOdAMIV +VIPZpDU+ao05n2fxTHUXXMQDqwjMG86zvYrpcDkAhwSxP4bjA+OZ/i9k5QKsB5V7CZY CfcrFxiSC1t7JGFSj/J+Ikg7Pfoveu3M91GJu9scEjZH3dJSYXNZhJSCRxnEzPGgFLDg buuxeAf7x5AVLIsS3SlzZ5aQV7XUEHVqEdnJ0/dG+vKJtVFSenjH6ve6NFGTONcMzOME ekI0fm9iLDob9rYvyPI9lzdhNEI6s+r7yfbAyAYjt3RjIg/tJmCUs/yEVprwArdQlhr3 1AfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YJqwphis; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6-v6si36859201pgd.579.2018.06.11.20.52.12; Mon, 11 Jun 2018 20:52:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YJqwphis; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932796AbeFLDok (ORCPT + 99 others); Mon, 11 Jun 2018 23:44:40 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:40903 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751862AbeFLDoj (ORCPT ); Mon, 11 Jun 2018 23:44:39 -0400 Received: by mail-pg0-f66.google.com with SMTP id l2-v6so10767608pgc.7 for ; Mon, 11 Jun 2018 20:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aUhT9jqKZFY72Z1/qW6kXOFlp/YvK0MiyVB6Pgj0070=; b=YJqwphisIRCDqe0OJEnV1AVA/egZDHO0t0vgf0zHEDeHBPj3k2ogDhGla6tYrCsU7k +F0DtIfHmxfJvt4BLhlXQZ8xbvzPsx4Jl51C+bzr+1IYjVHUFTDGcJR6OQL0SkNQ4275 RW6etGp285VtsmuQgl5HPBGGX+LQPNLuc6AfBC7vZFrLZL89Y6faU0tzdBakzAfr31KY sdo5Ctv+czeiUyWQdrpS2XGwPcYFS6+GNurnuhmNqDPMKwcj2SPHrCZJERz9IfnDoImC E8aZ4SQpBpxVIrkPpJ7ndSoYa80XME2AwZAskBiGrEcKd+Ic+i71wFvnhypT5SlmouLH Qclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aUhT9jqKZFY72Z1/qW6kXOFlp/YvK0MiyVB6Pgj0070=; b=tgAOgfAgXaX5WxbG1k9Ms/dUGwZC07K9nZWOSlLx0T1RB4Yy5A+7Nr3w8B7EIXzDZj E+4Mj8BFW4geHHJ6jTNOc3lvkGNm0Txg4Vhr6PGTu++/jzhYhc5QQyLSL1LB6WJ+W+Ng /Xlgc81bXhDcAuBg+tKEhlCgy+KuVB1kzwpz1Mnyl6B58Xt09BoV2XvQMz6RlA7khR8K MzghA5LGJ1zi7iMlRNgLKjDdlB6zL+Si+0dsetIz2/H/nCuHR68tziVaBkSX6xBtgTsx bN2z8NoIChuFxM2I81jV42ZLzZBDrjFo++K4sMqfmiRiu0DBpWgD1f2Kl3fAzp4NTYJi zPCw== X-Gm-Message-State: APt69E2w4H01/O3P1U7rySkWJhpjnEQ7LvS7G8vHaRm79wc5W1Ku5hqs dJHkSVDOYsjkFG8vfAKwtWc= X-Received: by 2002:a62:4785:: with SMTP id p5-v6mr1981645pfi.164.1528775079104; Mon, 11 Jun 2018 20:44:39 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id i17-v6sm32290369pfj.95.2018.06.11.20.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:44:38 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Boris Ostrovsky , Juergen Gross , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [PATCH] xen: add error handling for xenbus_printf Date: Tue, 12 Jun 2018 11:44:33 +0800 Message-Id: <1528775073-39322-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When xenbus_printf fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling xenbus_printf. Signed-off-by: Zhouyang Jia --- drivers/xen/manage.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 8835065..159694d 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -289,8 +289,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path, return; } - if (sysrq_key != '\0') - xenbus_printf(xbt, "control", "sysrq", "%c", '\0'); + if (sysrq_key != '\0') { + err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0'); + if (err) { + pr_err("Error %d writing sysrq code in control/sysrq\n", + err); + xenbus_transaction_end(xbt, 1); + return; + } + } err = xenbus_transaction_end(xbt, 0); if (err == -EAGAIN) @@ -342,7 +349,11 @@ static int setup_shutdown_watcher(void) continue; snprintf(node, FEATURE_PATH_SIZE, "feature-%s", shutdown_handlers[idx].command); - xenbus_printf(XBT_NIL, "control", node, "%u", 1); + err = xenbus_printf(XBT_NIL, "control", node, "%u", 1); + if (err) { + pr_err("Error %d writing %s\n", err, node); + return err; + } } return 0; -- 2.7.4