Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp119901imm; Thu, 14 Jun 2018 16:35:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKNUd43jjSGvAii4QFk0DAq6CbysHmDw/rSNg15PEvvoR8BW3ecJAoLjiPuU9H0TLA8lhyG X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr5092614plo.305.1529019354859; Thu, 14 Jun 2018 16:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529019354; cv=none; d=google.com; s=arc-20160816; b=Lnqd+NjX6dQmEm6L49BgTXm222xmsG9Ok5guaYAejOPbcv6yF2H2WpOkVYHYrrarKN Q/L6beJ2C81OK7nssr5N7uqU7Rf3k2Bita8V0ECV3mxImSYwF0ff5YMYWNSVmDMPoDkY Bnw+/bnSzUHSyjS2nVJKEIlYOjjxQfTI52px0pTa3b9aWVR5Ez0OMjwAW1rI/MlghAkP /i6t02a4cDgwouuPjhRhDIlLJz6aV4faRhTptv9aP0Ji3F0UKMmiWK4C36s1IG95aPya aH3A2CEj2utVAyB9Z5yRxy9P/ouyC+tccYLl+WddL/0D8zut/ut15Vdt5mWYQoixAtD1 q8fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=QQNKtzgcetzD86rnRxV18V5fUo1RGn/dAr7kXklW984=; b=M4YDZUry+NqNPK7vKR3/hvCcU85ogkOs0N/Pt9WygFAgA0GBc4XQfEMk3MZjMFg0zS zoOnB5vNogD92QVT1JaZHNMiF57a2/gIoY68acBKb/HnhQWbdYVgOelruDnsVOtg4/y0 v0lcwTDea0tbrEKsenjUlDK4dzteCMMVKJJrmVV5Z2sGgQXVP2NX+OhbUppyWsRPzn5D codtt5PgEVGKq1x1wKjybn9Xx8AfOrfZr/0509jDl6epesM//n2uCxaX3pFv4CXmF6Gn 7argFH8eGLE5yMHXfnYc9AnsQIpM7hhMlPLE1g1SKz7V7E7Yrue1UZJ3MQfmRuEbqW2t jCJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Lpd0b2j8; 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 w23-v6si6506278pfj.144.2018.06.14.16.35.40; Thu, 14 Jun 2018 16:35:54 -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=Lpd0b2j8; 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 S965150AbeFNXfH (ORCPT + 99 others); Thu, 14 Jun 2018 19:35:07 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34339 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965056AbeFNXfF (ORCPT ); Thu, 14 Jun 2018 19:35:05 -0400 Received: by mail-pg0-f67.google.com with SMTP id q4-v6so3611221pgr.1 for ; Thu, 14 Jun 2018 16:35:05 -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:in-reply-to:references; bh=QQNKtzgcetzD86rnRxV18V5fUo1RGn/dAr7kXklW984=; b=Lpd0b2j8lZ+cdOP+mO8pAvySQGlkOIr1Icdq5z1bYR6bavhGNUfothWV9No3jQGY2x JqA5NKln0ejaa6WxJPygaGrQIW1W/PQvUALoGww+45+RC8OyQDr0tEUkuhAA6yMkWpIo bfss6fpT1sdEwSdCbSIgqfGv7Il3i68DKsBkUSJf5jwHLfV7hYESVeNJynsJJVfC6yxM Ezf3Trtl02OVHu+TTQcfC42oQJILMJAk/f5NLr7VolQBs2Q5eqO3lptu3RctNAiuSIWa evPHRsDDjibdECqUMVpiUgfpDvGaADAbLVHbICRGEKpDhAUbjcmhWCUWg7FX9plBTF9s j9PQ== 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:in-reply-to :references; bh=QQNKtzgcetzD86rnRxV18V5fUo1RGn/dAr7kXklW984=; b=baecebo0NxQz85XGr55xh/k3F/xeDIZGN9CDGrfcG8SgA+uWVU66TYE8L8iTrZCPaa O1LDnSlaMdLBbHbymT7mOGqNnucCtSZr3YHEyaZV/aeGrqfRltH3nlEOVSO13FzCaSsF 0bur/h5JGbyjfM1SHR8G5bFw43vlcz5Ky1humgapIbXSoRelOSjdwUow+6bA5QtMvzGd HI813NydBBV8HwQnko69xYmQlt3oLLUHJLfqiYhK7Bt2Jfqn8FPPn8BGV8tG4gwvxyb+ XIcoeBrcO0dIg9+Dkse2ELcmXGS0HvBzcasTnsXV9np4p42y/vfac3vBDZuFrXchYFwt OsWw== X-Gm-Message-State: APt69E3rPS0qMyNW+RN/uIRFpcJ0eOLZcIMDHkqKO2OEHdyF73p+BSbr ZfmfIdMyqIAlDPTXjHJBuDg= X-Received: by 2002:a65:6147:: with SMTP id o7-v6mr4025702pgv.163.1529019305540; Thu, 14 Jun 2018 16:35:05 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id l11-v6sm6840491pff.50.2018.06.14.16.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 16:35:05 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Boris Ostrovsky , Juergen Gross , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] xen: add error handling for xenbus_printf Date: Fri, 15 Jun 2018 07:34:52 +0800 Message-Id: <1529019293-55493-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528775073-39322-1-git-send-email-jiazhouyang09@gmail.com> References: <1528775073-39322-1-git-send-email-jiazhouyang09@gmail.com> 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 --- v1->v2: - Add __func__. --- drivers/xen/manage.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 8835065..c93d8ef 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("%s: Error %d writing sysrq in control/sysrq\n", + __func__, err); + xenbus_transaction_end(xbt, 1); + return; + } + } err = xenbus_transaction_end(xbt, 0); if (err == -EAGAIN) @@ -342,7 +349,12 @@ 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("%s: Error %d writing %s\n", __func__, + err, node); + return err; + } } return 0; -- 2.7.4