From mboxrd@z Thu Jan 1 00:00:00 1970 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 B0DFCC4321E for ; Mon, 23 May 2022 11:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235207AbiEWL42 (ORCPT ); Mon, 23 May 2022 07:56:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235177AbiEWL42 (ORCPT ); Mon, 23 May 2022 07:56:28 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7108921BA; Mon, 23 May 2022 04:56:23 -0700 (PDT) Received: from fraeml735-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4L6G0N6q73z67njv; Mon, 23 May 2022 19:52:20 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml735-chm.china.huawei.com (10.206.15.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 23 May 2022 13:56:20 +0200 Received: from [10.47.87.6] (10.47.87.6) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 23 May 2022 12:56:19 +0100 Message-ID: <42350b3a-193f-a1a0-3ef7-13643e1101f0@huawei.com> Date: Mon, 23 May 2022 12:56:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 3/4] scsi: core: Cap shost max_sectors according to DMA optimum mapping limits To: Dan Carpenter , , , , , , , , , CC: , , , , , , , , , References: <202205210545.gkS834ds-lkp@intel.com> From: John Garry In-Reply-To: <202205210545.gkS834ds-lkp@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.87.6] X-ClientProxiedBy: lhreml748-chm.china.huawei.com (10.201.108.198) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On 23/05/2022 12:08, Dan Carpenter wrote: Thanks for the report > 50b6cb3516365c Dexuan Cui 2021-10-07 224 /* Use min_t(int, ...) in case shost->can_queue exceeds SHRT_MAX */ > 50b6cb3516365c Dexuan Cui 2021-10-07 225 shost->cmd_per_lun = min_t(int, shost->cmd_per_lun, > ea2f0f77538c50 John Garry 2021-05-19 226 shost->can_queue); > ea2f0f77538c50 John Garry 2021-05-19 227 > 2ad7ba6ca08593 John Garry 2022-05-20 @228 if (dma_dev->dma_mask) { > ^^^^^^^^^^^^^^^^^ I knew that we fixed up dma_dev to be non-NULL, but I thought it was earlier in this function... > The patch adds a new unchecked dereference > > 2ad7ba6ca08593 John Garry 2022-05-20 229 shost->max_sectors = min_t(unsigned int, shost->max_sectors, > 2ad7ba6ca08593 John Garry 2022-05-20 230 dma_opt_mapping_size(dma_dev) >> SECTOR_SHIFT); > 2ad7ba6ca08593 John Garry 2022-05-20 231 } > 2ad7ba6ca08593 John Garry 2022-05-20 232 > 0a6ac4ee7c2109 Christoph Hellwig 2017-01-03 233 error = scsi_init_sense_cache(shost); > 0a6ac4ee7c2109 Christoph Hellwig 2017-01-03 234 if (error) > 0a6ac4ee7c2109 Christoph Hellwig 2017-01-03 235 goto fail; > 0a6ac4ee7c2109 Christoph Hellwig 2017-01-03 236 > d285203cf647d7 Christoph Hellwig 2014-01-17 237 error = scsi_mq_setup_tags(shost); > 542bd1377a9630 James Bottomley 2008-04-21 238 if (error) > 542bd1377a9630 James Bottomley 2008-04-21 239 goto fail; > d285203cf647d7 Christoph Hellwig 2014-01-17 240 > ^1da177e4c3f41 Linus Torvalds 2005-04-16 241 if (!shost->shost_gendev.parent) > ^1da177e4c3f41 Linus Torvalds 2005-04-16 242 shost->shost_gendev.parent = dev ? dev : &platform_bus; > 3c8d9a957d0ae6 James Bottomley 2012-05-04 @243 if (!dma_dev) > ^^^^^^^^ Cheers, John