From patchwork Thu Jun 21 02:55:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 10479083 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 867F060230 for ; Thu, 21 Jun 2018 02:55:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8E22897D for ; Thu, 21 Jun 2018 02:55:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D44F289C4; Thu, 21 Jun 2018 02:55:36 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 DED912897D for ; Thu, 21 Jun 2018 02:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbeFUCzf (ORCPT ); Wed, 20 Jun 2018 22:55:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:34137 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754284AbeFUCze (ORCPT ); Wed, 20 Jun 2018 22:55:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 74B3CABDF; Thu, 21 Jun 2018 02:55:33 +0000 (UTC) Received: from starscream.home.jeffm.io (starscream-1.home.jeffm.io [IPv6:2001:559:c0d4::1fe]) by mail.home.jeffm.io (Postfix) with ESMTPS id DBBA581AD3E5; Wed, 20 Jun 2018 22:54:38 -0400 (EDT) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id 9509981637; Wed, 20 Jun 2018 22:55:31 -0400 (EDT) From: jeffm@suse.com To: linux-xfs@vger.kernel.org Cc: Dave Chinner , Eric Sandeen , Jeff Mahoney Subject: [PATCH] mkfs: fix divide-by-zero in align_ag_geometry Date: Wed, 20 Jun 2018 22:55:20 -0400 Message-Id: <20180621025520.9115-1-jeffm@suse.com> X-Mailer: git-send-email 2.15.1 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Mahoney Commit 051b4e37f5e (mkfs: factor AG alignment) factored out the AG alignment code into a separate function. It got rid of redundant checks for dswidth != 0 but did too good a job since now it doesn't check at all. When we hit the check to see if agsize is a multiple of stripe width: (cfg->agsize % cfg->dswidth), we crash on a divide by zero. This patch re-adds the check to the top of align_ag_geometry. Fixes: 051b4e37f5e (mkfs: factor AG alignment) Signed-off-by: Jeff Mahoney --- mkfs/xfs_mkfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 78d0ce5d..28a7e70c 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2670,7 +2670,7 @@ align_ag_geometry( uint64_t tmp_agsize; int dsunit = cfg->dsunit; - if (!dsunit) + if (!dsunit || !cfg->dswidth) goto validate; /*