From patchwork Sun Jan 22 06:47:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jianhong.Yin" X-Patchwork-Id: 9530783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C13660431 for ; Sun, 22 Jan 2017 06:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B2FF28119 for ; Sun, 22 Jan 2017 06:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B5DB2833A; Sun, 22 Jan 2017 06:47:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6C0A28119 for ; Sun, 22 Jan 2017 06:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750964AbdAVGrR (ORCPT ); Sun, 22 Jan 2017 01:47:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53800 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886AbdAVGrQ (ORCPT ); Sun, 22 Jan 2017 01:47:16 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C93F624C9; Sun, 22 Jan 2017 06:47:08 +0000 (UTC) Received: from dhcp-13-42.nay.redhat.com (dhcp-13-42.nay.redhat.com [10.66.13.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0M6l6V1001745; Sun, 22 Jan 2017 01:47:07 -0500 From: yin-jianhong@163.com To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, "Jianhong.Yin" Subject: [PATCH] [nfs-utils] fix mount fail that caused by uninitialized struct Date: Sun, 22 Jan 2017 14:47:04 +0800 Message-Id: <1485067624-3659-1-git-send-email-yin-jianhong@163.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 22 Jan 2017 06:47:08 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Jianhong.Yin" recent changes of utils/mount cause a regression mount fail: https://bugzilla.redhat.com/show_bug.cgi?id=1415024 can not reproduce it on x86_64(gcc on x86_64 might do struct initialize by default, I'm not sure). but it can be reproduced always on platform ppc64le aarch64. Signed-off-by: Jianhong Yin --- utils/mount/network.c | 1 + utils/mount/stropts.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/utils/mount/network.c b/utils/mount/network.c index 7dceb2d..d1c8fec 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -1638,6 +1638,7 @@ int nfs_options2pmap(struct mount_options *options, struct pmap *nfs_pmap, struct pmap *mnt_pmap) { struct nfs_version version; + memset(&version, 0, sizeof(version)); if (!nfs_nfs_program(options, &nfs_pmap->pm_prog)) return 0; diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 387d734..a9ff95d 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -517,6 +517,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options, int checkv4) unsigned long protocol; struct pmap mnt_pmap; + /* initialize structs */ + memset(&nfs_pmap, 0, sizeof(struct pmap)); + memset(&mnt_pmap, 0, sizeof(struct pmap)); + /* * Version and transport negotiation is not required * and does not work for RDMA mounts.