Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752357AbcLCKvT (ORCPT ); Sat, 3 Dec 2016 05:51:19 -0500 Received: from m50-134.163.com ([123.125.50.134]:56207 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750833AbcLCKvS (ORCPT ); Sat, 3 Dec 2016 05:51:18 -0500 From: Pan Bian To: Boris Ostrovsky , David Vrabel , Juergen Gross , xen-devel@lists.xenproject.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] xen: xenbus: set error code on failure Date: Sat, 3 Dec 2016 18:49:26 +0800 Message-Id: <1480762166-4883-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DtGowAB3veU2o0JYeYkpIg--.20858S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gw4kXw15WFW8AFyfZrWUJwb_yoWDJFgE9a 1kXry7Zr1jkr4UZ3yUC3y3Zry0yw48Zry8Z3W7KFW3C34rCr4DAFZrZFn5Cw1UWr4I9rWq 9w1kXFy7Cr17JjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUeLYFJUUUUU== X-Originating-IP: [222.131.246.88] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBzxk1claDscctagAAs1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 940 Lines: 31 In function xenstored_local_init(), the value of return variable err should be negative on errors. But the value of err keeps 0 even if the call to get_zeroed_page() returns a NULL pointer. This patch assigns "-ENOMEM" to err on the error branch. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188721 Signed-off-by: Pan Bian --- drivers/xen/xenbus/xenbus_probe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 33a31cf..f87d047 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -708,8 +708,10 @@ static int __init xenstored_local_init(void) /* Allocate Xenstore page */ page = get_zeroed_page(GFP_KERNEL); - if (!page) + if (!page) { + err = -ENOMEM; goto out_err; + } xen_store_gfn = xen_start_info->store_mfn = virt_to_gfn((void *)page); -- 1.9.1