Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1036245imm; Fri, 15 Jun 2018 10:07:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKII9uP0lCRxqIxAUTMohegdatmreHPihGytw9ChJ/iEuOk0/heB62TxoueVSsj/6AYaM6wQ X-Received: by 2002:a17:902:56e:: with SMTP id 101-v6mr2891466plf.25.1529082424670; Fri, 15 Jun 2018 10:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529082424; cv=none; d=google.com; s=arc-20160816; b=ovbi+HlZRw9Vh6WLI+m4zFfJ8La67okGE2cMF8dEaL3Mj/qe5mWeDS9aJtbzGA2fmu 1nW8bQf0R9vb7hmql+OPFO2jE6MPuwDzVsMvejEnOrqbfcfpEYafVOY1Za/WkODa2+r5 GcA/CHWR0ER2Bq/o7cnu2cmrTeoHhktyhIpmfAMLkeUpKOuoVAkInQU8Df3IwGl03dT+ 9tpkAolML0w1dbor8uCXphxtoMkyRTipieWuGl+2gxw/YgR11HUvCQjtLws1Am+roDof MXyvFNTtkBdq4guZPQOfK9fXdFrzIJDyVrDk7R91351HreaYCv8fZpL5SUDnEEKTTck4 jogA== 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=2NJCOgSTmBo/S/26rP7nZe4v0Cv4TXskvLFwGiuPfq0=; b=fkHkSnnb1sh9WO+KuRuXU0vWQtm+FL0KQCKidWQXhWR9otNkZ3jP6eQnxjChjZNZX6 s8CD1XPk4qGHtifpP5y5DoMgl+57TddNG7p33/KzcmfAnbGCiQaUZnbynF6uZcobLdcL /G/iRnCTeCzNZzzO3p26Ixr/tz4B1LVudIFBtb05gQkYKUoEBj1qtaYfk7+cpCifz1OH H5yu+2IIwZ+X0SGWWaZpv+mkvUOOFN4lpOpmc2OVqXaRmucW11FCyk+5wcgkhGD5NB+H q+eivx8rPhJV2m44lbxAzuOGDIzKaRnnP2hqppA1/XRcRgYn5IIt1oCrIhyjSk/3r/Z3 sQZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UUeydfWe; 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 q13-v6si8639149pll.72.2018.06.15.10.06.49; Fri, 15 Jun 2018 10:07:04 -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=UUeydfWe; 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 S1756356AbeFORGU (ORCPT + 99 others); Fri, 15 Jun 2018 13:06:20 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:44855 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756341AbeFORGS (ORCPT ); Fri, 15 Jun 2018 13:06:18 -0400 Received: by mail-pl0-f66.google.com with SMTP id z9-v6so5656751plk.11; Fri, 15 Jun 2018 10:06:18 -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=2NJCOgSTmBo/S/26rP7nZe4v0Cv4TXskvLFwGiuPfq0=; b=UUeydfWeHA1Lyfk1iYd+gympQymtsWJssZ1J6p7R5wUJqSaZB9pqT6J3M//Hc7HvEX +EWldFYq3L62hxvrjtKSULdiIxly1yxnj1/ySkkLsOLM+IwQIxSqOFD8q++GQRkTEyNC 58FBAx7cKYGomvQEGR0L6qHumviMj9SD8fON4ST8f6qvS003/mNUXXtDR58efuWP0Vqg KSGO7GIEDYTiQ8gw8E6g3FjdU+PTe85VcAX1I5TajTYP1sSq8ra2DjsnlrEuRRTjOrMJ R3Y0UaY/oTUmyM8A8tTrn8Deqn7nlCRr+EcxaMf0DhqFJuSkLIm29a4oJbYGfHALWpru RgaQ== 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=2NJCOgSTmBo/S/26rP7nZe4v0Cv4TXskvLFwGiuPfq0=; b=KMNXSw8sIOw7wylUaXqL/ETQ1pFEP/qpJHEvLbf/rzwjjUUIlCo/c3l0McbzrkkysH NQRmDk/s5st0RUtXp7eDVVUDHF4uLZ/PiwtV4O23N2rLx57qi6IQ1HAi4FmvnGnTS5fs IEs8wEzM+fnwXHVW/0vgXHG5TUszFLEVn41xguuGvIiON4812ARbLXbkeFbyka9pv4rv 066SIPeiX7KSZNC5+O1JrIbiyE06url4qpJMEtZG0FB7g45vz/md+KAKwPccOSwtQYqh PYCHq1AwFWIU7Db1jGoiogk0twGwPvBr3xBES3vik9v7fIE2CS0Wg9QxpKDiDiCEOQ+0 06VQ== X-Gm-Message-State: APt69E0oyDYI5XTBMpwZe8Nod98U4u5kBi9CTGv/vaKwlI61/pJ2/g39 v0raDXGilNeQpEdfKCm6OXM= X-Received: by 2002:a17:902:1127:: with SMTP id d36-v6mr2997700pla.267.1529082378453; Fri, 15 Jun 2018 10:06:18 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id c191-v6sm13260182pfg.48.2018.06.15.10.06.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 10:06:17 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Juergen Gross , Boris Ostrovsky , xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] xen/scsiback: add error handling for xenbus_printf Date: Sat, 16 Jun 2018 01:06:12 +0800 Message-Id: <1529082372-59097-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528775185-39467-1-git-send-email-jiazhouyang09@gmail.com> References: <1528775185-39467-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: - Use xenbus_dev_error to report errors. --- drivers/xen/xen-scsiback.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 7bc88fd..cec2133 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1027,8 +1027,10 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state, scsiback_del_translation_entry(info, vir); } } else if (!try) { - xenbus_printf(XBT_NIL, info->dev->nodename, state, - "%d", XenbusStateClosed); + if (xenbus_printf(XBT_NIL, info->dev->nodename, state, + "%d", XenbusStateClosed)) + xenbus_dev_error(info->dev, err, + "%s: writing %s", __func__, state); } } @@ -1067,8 +1069,10 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op, snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent); val = xenbus_read(XBT_NIL, dev->nodename, str, NULL); if (IS_ERR(val)) { - xenbus_printf(XBT_NIL, dev->nodename, state, - "%d", XenbusStateClosed); + if (xenbus_printf(XBT_NIL, dev->nodename, state, + "%d", XenbusStateClosed)) + xenbus_dev_error(info->dev, err, + "%s: writing %s", __func__, state); return; } strlcpy(phy, val, VSCSI_NAMELEN); @@ -1079,8 +1083,10 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op, err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u", &vir.hst, &vir.chn, &vir.tgt, &vir.lun); if (XENBUS_EXIST_ERR(err)) { - xenbus_printf(XBT_NIL, dev->nodename, state, - "%d", XenbusStateClosed); + if (xenbus_printf(XBT_NIL, dev->nodename, state, + "%d", XenbusStateClosed)) + xenbus_dev_error(info->dev, err, + "%s: writing %s", __func__, state); return; } -- 2.7.4