Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751443AbcLEIWy (ORCPT ); Mon, 5 Dec 2016 03:22:54 -0500 Received: from m12-16.163.com ([220.181.12.16]:57825 "EHLO m12-16.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998AbcLEIWx (ORCPT ); Mon, 5 Dec 2016 03:22:53 -0500 From: Pan Bian To: Juergen Gross , David Vrabel , Boris Ostrovsky , xen-devel@lists.xenproject.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1 v2] xen: xenbus: set error code on failure Date: Mon, 5 Dec 2016 16:22:22 +0800 Message-Id: <1480926142-19882-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: EMCowAAHX7e9I0VYZkuYEw--.1055S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw1DKw4rGF47ur43AF43KFg_yoW3KFgE9a n5Xry7Zr1qva1DGayUXa13Zryjkr4xZr95uw1ftF4fJ3y8Cw48ArW7Zrs8GwnxWrsFyasF 93yqqFy3ury7tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5uuWJUUUUU== X-Originating-IP: [106.120.213.17] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBzx83claDsdbgWwAAsc Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 813 Lines: 27 Variable err is initialized with 0. As a result, the return value may be 0 even if get_zeroed_page() fails to allocate memory. This patch fixes the bug, initializing err with "-ENOMEM". v1 is reviewed by: Juergen Gross Signed-off-by: Pan Bian --- drivers/xen/xenbus/xenbus_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 33a31cf..8178d5b 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -702,7 +702,7 @@ static int __init xenbus_probe_initcall(void) */ static int __init xenstored_local_init(void) { - int err = 0; + int err = -ENOMEM; unsigned long page = 0; struct evtchn_alloc_unbound alloc_unbound; -- 1.9.1