Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4851724imm; Mon, 11 Jun 2018 21:08:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINUD8sseWGlkq5Sy0Q83HWIBII5uT0NpfRqW6Yg2y50QpMj8/iw7+L0k/zj4dWxyAvSpzV X-Received: by 2002:a17:902:52ee:: with SMTP id a101-v6mr2125534pli.131.1528776503573; Mon, 11 Jun 2018 21:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528776503; cv=none; d=google.com; s=arc-20160816; b=KwsvFcn5lnu9pgMIunrfTiC6U1zTSC284/GA2u6WLsMJxCuRLtqvmSSznDbAkFz28p W4ZaFMsNdmWFTjZIhW68oqvqNxOm1yYZMiJFfbUl3krW6IIv5tzpIlkWfUqY91uSr7QT rHcsxBkGXfGqkmCmQWKRHL/rlh8zD74DkTheeoy9ak0Ho9XAQ2sDvC6mM2fgUE+Evme9 KAtQfB5+eDlDvsqCjXPLhG9GMbiuOgVZksmk/4W+zcQNdbVBgTxxFX4PymDZDZv6ojut rB0rku2Ew9ieWy0QwLgj8IB9XlZCqiTQk+Ik0nRE0QNJUKbGi3dj5vTHcVdzGPIAO4/v D5pQ== 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=x7I56ELwwevdipu2gQ2jZ0MqSh/U5Nq/u+3Tv6XMrIk=; b=qX8CkvLjs36Abc9egZsadH5/6Ul/bhx3uvK2flU/tmPdvq8qR1IPsAfHK0ehVCAXy7 qGb8xKZ6XVtOsizbWvND0U+7g/0tIitu+3TfB5qObLh/WznHY9xBe7F2KbakS5+2K7fY zG7XY1bBMfv7vl1EfV3Q3rB4bjRLdPvo+9eNk/bWCAX2HslKQDEg89gFlrWto739xmsm PUzaULyMkecyD/Uq6WSHoddLXEReq0NmvHdl3caJvedSMmL3w+ccMBAxMIl6gtKXpMq2 6TXcFvppmbZe0UKlPf/FzAUWmHbUVJp/2tqLmqJWk5QyDehCQNuCEOAdHaky14f5Tz0C Z7mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZGBI6MhU; 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 e8-v6si17256511pfi.23.2018.06.11.21.08.09; Mon, 11 Jun 2018 21:08:23 -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=ZGBI6MhU; 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 S933235AbeFLDqd (ORCPT + 99 others); Mon, 11 Jun 2018 23:46:33 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34438 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932460AbeFLDqb (ORCPT ); Mon, 11 Jun 2018 23:46:31 -0400 Received: by mail-pl0-f68.google.com with SMTP id g20-v6so13559066plq.1; Mon, 11 Jun 2018 20:46:31 -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=x7I56ELwwevdipu2gQ2jZ0MqSh/U5Nq/u+3Tv6XMrIk=; b=ZGBI6MhUSCmN4U9KPF8qhYDTKjTpYoa7XYk6mp7oztHY8iuU3Ol1qW44ttGeI6XQX3 hDW1H3Jef5vL0A84cVZmLbyO5rU4DIdWxXA8gUZRS+nDQtcH7e4aeGJw5XRGfhER7T47 fnWvDdUeEtQI8DI1g74Fh0ZOytNtXJzRLPrzcjVK4S/jhD7MX579uMmLGUaGbIyEr1mF ZkX9C0HcDclUkKuv0UZxJM0ux96tbV1udAEXh+inXygsaaoAnslimWNeFOrn2E+9NBG3 J09U2J6YezxM3AlD0+Qr+pjTjjMxbIK3W1a/uSg9z7OGQ7mWtc9kTf3CIm4PJHCkQF+l MaiA== 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=x7I56ELwwevdipu2gQ2jZ0MqSh/U5Nq/u+3Tv6XMrIk=; b=Y8ZsLaC8s/mYYH+tvZ+NgKeU9JygUm8rYvgGev/j+60C36ufGxb8e59EZwqcm37HQS fwUsJFiZDLuTkGrp/A6jV2gtSExaGIcmCAzsW4P1Rk0+8AnXVQbSXsHk8F88jI4hLhD0 DfC7IPcLN1hWOTO6fJ3kcO0i3m6DtWcefDxXgIUQT1/a2VysyELceqnZMbM4Y3GXt8hN GfNR5hH6NkSFIMbkXWYqV2D2StNhI0kaX9f+0h2zNW/hFd9/v4xhN/XG1jFm5nXyMPcg E8meCBJJi1L2csU9Td7W2eeJV3cKynbI/iwZUaPpc6RaRTsb5upWRcCTcHy7BfAWQ0bj u7Qg== X-Gm-Message-State: APt69E2vQNW+91kqtf5ZcgbNHXVVkvv8ll/6WNmzGfP64eAc56Kh4jl7 M202Y1cu0VtkJONluQIV1zg= X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr2069734pls.284.1528775191021; Mon, 11 Jun 2018 20:46:31 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id e189-v6sm33100393pfc.134.2018.06.11.20.46.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:46:30 -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] xen/scsiback: add error handling for xenbus_printf Date: Tue, 12 Jun 2018 11:46:25 +0800 Message-Id: <1528775185-39467-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/xen-scsiback.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 7bc88fd..13ab54c 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1027,8 +1027,9 @@ 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)) + pr_err("xenbus_printf error %s\n", state); } } @@ -1067,8 +1068,9 @@ 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)) + pr_err("xenbus_printf error %s\n", state); return; } strlcpy(phy, val, VSCSI_NAMELEN); @@ -1079,8 +1081,9 @@ 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)) + pr_err("xenbus_printf error %s\n", state); return; } -- 2.7.4