From patchwork Thu May 4 20:17:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Butterfield X-Patchwork-Id: 9712657 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 809FA6038F for ; Thu, 4 May 2017 20:17:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A6F28691 for ; Thu, 4 May 2017 20:17:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A03D2869F; Thu, 4 May 2017 20:17:48 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 1AFA8286A4 for ; Thu, 4 May 2017 20:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752600AbdEDURr (ORCPT ); Thu, 4 May 2017 16:17:47 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:33709 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752306AbdEDURr (ORCPT ); Thu, 4 May 2017 16:17:47 -0400 Received: by mail-it0-f67.google.com with SMTP id v135so3003387itv.0 for ; Thu, 04 May 2017 13:17:46 -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:in-reply-to:references; bh=yBvX7E39OmTrH/RegCB5+pLjPTicmceoIG3/5RBGCdk=; b=beF+7P1lalO2GVbNPD4DdlH6L+ThdUfdffnOiBBeNXadWat/n5LUcY8rOXn5nSo/XB WOq+TxMZCzqeaxE4VkHgBRdTvWg5nOGjxzRHiYdo53xJ3iZyYWK2dWDNMSzC8/zw1TID PK7C8OmpkQaZL1D7C/7Jm4W48042HEW2uzB7LCeps+voEOX5kut83I1WX02kTmtRUb/C kIATcj4l00O6T4QN3t7NPZrKumqvevwtd6vH+LI7/S/UM8g3hOxahkeZRzhMhiKvXYbc T5FI+0ZuvPJvTnzuds/bHeI56PxZUw5FG4j5MQFJguHWoeh5kxyoMsWhKmv7D6zh7lZ8 +b0A== 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:in-reply-to :references; bh=yBvX7E39OmTrH/RegCB5+pLjPTicmceoIG3/5RBGCdk=; b=ie/4Oup23o4kmzhw58X24vIjJbS14/mxvBzYPn2bNoh5zoM4Yivc5fUHblS2JBsl8J 87HE6/ITA4ISSh3hvDhUCl3o+ukZxlJtlHIUn4FySYao9dMdnHqvpfo3+I5MNbv7dY1c FNrLQoJKShoTilgzVtabHDdlR6cnklF5trKM4HwQiroiCcL2yZH4dqU3OVJaUCQ4N8HX P/YNXRNqGMgdOPdpLHOX3e0mItXThqLx4tLvCQa7AYk+oMTY/ejlqyQEsscxpe+lUtWL 7FyH35hX/puY8g6PcXfXgSu7kK2p9pOfLDmX7DSJDQMMy1eye1PanZInrtbtzDCmY1yc WqUA== X-Gm-Message-State: AN3rC/7/UJSXqUFR5bmG5sxSELaJS9mR865tb+tTLbmWhHoN4M2GkmdX TwI7Vy1TKeabrg== X-Received: by 10.36.46.193 with SMTP id i184mr4827829ita.51.1493929066250; Thu, 04 May 2017 13:17:46 -0700 (PDT) Received: from localhost.localdomain (c-73-181-28-74.hsd1.co.comcast.net. [73.181.28.74]) by smtp.gmail.com with ESMTPSA id c82sm11120266ioe.62.2017.05.04.13.17.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 May 2017 13:17:45 -0700 (PDT) From: David Butterfield To: target-devel@vger.kernel.org Cc: David Butterfield Subject: [PATCH] tcmu_rbd_open() detect/fail if block_size is zero Date: Thu, 4 May 2017 14:17:28 -0600 Message-Id: <20170504201728.25807-2-dab21774@gmail.com> X-Mailer: git-send-email 2.12.2.575.gb14f27f In-Reply-To: <20170504201728.25807-1-dab21774@gmail.com> References: <20170504201728.25807-1-dab21774@gmail.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Modify the check of the return from tcmu_get_attribute("hw_block_size") to fail if the returned value is zero, so as to avoid dividing by it a few lines later. Signed-off-by: David Butterfield --- rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rbd.c b/rbd.c index 852338d..c8019b5 100644 --- a/rbd.c +++ b/rbd.c @@ -411,7 +411,7 @@ static int tcmu_rbd_open(struct tcmu_device *dev) config += 1; /* get past '/' */ block_size = tcmu_get_attribute(dev, "hw_block_size"); - if (block_size < 0) { + if (block_size <= 0) { tcmu_dev_err(dev, "Could not get hw_block_size\n"); ret = -EINVAL; goto free_state;