From patchwork Mon Feb 14 10:33:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung CHOI X-Patchwork-Id: 542709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92C92C433F5 for ; Mon, 14 Feb 2022 21:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbiBNVSS (ORCPT ); Mon, 14 Feb 2022 16:18:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiBNVSR (ORCPT ); Mon, 14 Feb 2022 16:18:17 -0500 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD16108BE4 for ; Mon, 14 Feb 2022 13:18:06 -0800 (PST) Received: from epcas3p2.samsung.com (unknown [182.195.41.20]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220214211801epoutp038351e3be4c1c2bc015c4cc8c13461222~Tw7eC-j2n3003630036epoutp03c for ; Mon, 14 Feb 2022 21:18:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220214211801epoutp038351e3be4c1c2bc015c4cc8c13461222~Tw7eC-j2n3003630036epoutp03c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1644873481; bh=kLg3y1C57MGd7CXzhXTwI+7lw2u17ZSVQ9SR0owpbzU=; h=Subject:Reply-To:From:To:Date:References:From; b=dBF2VOqNcZ4j2L+Ow/qQgKwqFiInlx3/E1am2ekyouxZMQUsOlERyRyJwmmjbQM7N Z6XP4ro9JYhmbItyrvvV6HypJm7+POAEPA9VQZ16hK5n12gxA0k9juEFY1Jsn/GzDw HHq4oIoI/Y8T/gU2NboNhpFS+oroYhMykLZiWXag= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas3p4.samsung.com (KnoxPortal) with ESMTP id 20220214211801epcas3p453913a49631a117b8d2f4955cfe6cfb4~Tw7dcAUIH2286722867epcas3p4_; Mon, 14 Feb 2022 21:18:01 +0000 (GMT) Received: from epcpadp4 (unknown [182.195.40.18]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4JyHBK1N72z4x9Pv; Mon, 14 Feb 2022 21:18:01 +0000 (GMT) Mime-Version: 1.0 Subject: [PATCH] scsi: ufs: Fix divide zero case in ufshcd_map_queues() Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: ALIM AKHTAR , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "bvanassche@acm.org" , "beanhuo@micron.com" , Daejun Park , "adrian.hunter@intel.com" , "cang@codeaurora.org" , "asutoshd@codeaurora.org" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <1891546521.01644873481638.JavaMail.epsvc@epcpadp4> Date: Mon, 14 Feb 2022 19:33:52 +0900 X-CMS-MailID: 20220214103352epcms2p79697c0fcaa2755dd89af9de887ff14cd X-Sendblock-Type: AUTO_CONFIDENTIAL X-CPGSPASS: Y X-CPGSPASS: Y X-Hop-Count: 3 X-CMS-RootMailID: 20220214103352epcms2p79697c0fcaa2755dd89af9de887ff14cd References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to "struct blk_mq_queue_map" must be a vaild value. If nr_queues is set to 0, the system may encounter the "divide zero" depending on the type of architecture. blk_mq_map_queues() -> queue_index() Signed-off-by: Jinyoung Choi Reviewed-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 41d85b69fa50..36c5ca62ae0c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2674,21 +2674,21 @@ static int ufshcd_map_queues(struct Scsi_Host *shost) for (i = 0; i < shost->nr_maps; i++) { struct blk_mq_queue_map *map = &shost->tag_set.map[i]; switch (i) { case HCTX_TYPE_DEFAULT: case HCTX_TYPE_POLL: map->nr_queues = 1; break; case HCTX_TYPE_READ: map->nr_queues = 0; - break; + continue; default: WARN_ON_ONCE(true); } map->queue_offset = 0; ret = blk_mq_map_queues(map); WARN_ON_ONCE(ret); } return 0; }