Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp26753pxb; Tue, 12 Apr 2022 15:49:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN0bum5DHk5YQq8IvGRxm9CoJ/S2oIzQm70ga9rJylCi5sOGE4hTkrmJyp2NxhBMo9NTjW X-Received: by 2002:a17:90b:4c12:b0:1cb:4b66:2dc6 with SMTP id na18-20020a17090b4c1200b001cb4b662dc6mr7393215pjb.140.1649803792762; Tue, 12 Apr 2022 15:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649803792; cv=none; d=google.com; s=arc-20160816; b=RD+fFp7Xk7dro4RK7TiiTAyDlF2AHaLolyQQO7XOlHzBP7ezNgrERH299HMWyCdRsY D3f8pXadmuAO2XMUzBGcPzOCAQHbdDpTWhYN/a9EUEg9PX2XoEjiKCjSjr2fWHqgJxid F5i9fLkAguiG1mn9glAIcTu4ZU+EJ6W7uObAlv5fX+weqffnPKFAeSOmKUA+Y2dNpOng O733kuulfyRlnQBNI0aO1g5A/s6wlLJkwu5gqEyNrJMFjEl5CUGYOJ2h+7LRQ5faHSPW zB960cSlBux3iKawB57yk+1K/LP/Jwf5X94nv5tLHCtnXR/pyliPsNczhLSsO6Y2MllN sQ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ST9+FEdaj4fuxRcgKDA5xYr0xFYFj3jPfwMs5qzaW6U=; b=aCuGvkwGoFCEMGM/vL7JAc8ipkiKP1TM9rjQmR7Xp3OU/kOH2tG1mcB6mNScfV/vbU NKTYk9IVMG6D6FOCvic6v3dvrLB367HBcGSICJp+YSD3/LMX+I2wTARqfEG0MyqVTmdz +2mRzxVILZf+aIYd8EeA9c2cgsg1ndN4L3yLTUXqv3eXjMtoDHsYp3CGXGQ9bePOcphz IERX/yQ3FIz2uWRVnR4vU70PF/03HHtqAElz4OhP9OvihBE+6vQAFw8HTzmBS3FxfWae PfVH3+NlUCBp/EpQLxA56kQGimtZc0UTjHBSg182kr+i9LoocLspZM67MFpswLdnv5+f 6fWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ahi4SHTq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h18-20020a17090aea9200b001cb6eb55242si9664671pjz.131.2022.04.12.15.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:49:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ahi4SHTq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75BD51C1ED1; Tue, 12 Apr 2022 14:31:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344836AbiDKQZ4 (ORCPT + 99 others); Mon, 11 Apr 2022 12:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234414AbiDKQZy (ORCPT ); Mon, 11 Apr 2022 12:25:54 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C758A30555 for ; Mon, 11 Apr 2022 09:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649694219; x=1681230219; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ltUQurSEf7syUrN+loaIb4/tJxXmlbA0TKblHJomdWg=; b=ahi4SHTqSKN+zFW1wGR5yRQoIz4yi5z+WFFITKrcewGIr49tzqZr21JX juDlPzHuCEflPetmSQV/ZKX6keSpLiSSNib0UBeSF3pVuAPZv4B2NaGUq ufpcgD2lckxl9rj5pu1pWccK7UX7hSeMZOnQK6vVGmFn9HotZniKZn0IS Cz2yiUjukw8TRc/iCPq3s2QNG1F7BETsdlUMBdalKER/sapXPUHhT0qV6 N3+GZIJLdzb9KhZive3E5zGBdjGky8HD2Wktlp453PvWxCl21CvWFxC+G fTs4R6DVe7ZNzm5qQpx9oi1rtsVf8te0Z6y2pl7ThH0RLUbWjgz6h3By/ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10314"; a="244039394" X-IronPort-AV: E=Sophos;i="5.90,252,1643702400"; d="scan'208";a="244039394" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 09:23:39 -0700 X-IronPort-AV: E=Sophos;i="5.90,252,1643702400"; d="scan'208";a="572279148" Received: from prposam-mobl.amr.corp.intel.com (HELO [10.212.162.151]) ([10.212.162.151]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 09:23:26 -0700 Message-ID: <18cb711a-de2a-69e3-d753-7012a67bf2a7@linux.intel.com> Date: Mon, 11 Apr 2022 10:28:11 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.5.0 Subject: Re: [PATCH] ASoC: SOF: Intel: Check the bar size before remapping Content-Language: en-US To: Zheyu Ma , lgirdwood@gmail.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, peter.ujfalusi@linux.intel.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, sound-open-firmware@alsa-project.org References: <20220409143950.2570186-1-zheyuma97@gmail.com> From: Pierre-Louis Bossart In-Reply-To: <20220409143950.2570186-1-zheyuma97@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/9/22 09:39, Zheyu Ma wrote: > The driver should use the pci_resource_len() to get the actual length of > pci bar, and compare it with the expect value. If the bar size is too > small (such as a broken device), the driver should return an error. > > Signed-off-by: Zheyu Ma > --- > sound/soc/sof/intel/pci-tng.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/sof/intel/pci-tng.c b/sound/soc/sof/intel/pci-tng.c > index 6efef225973f..7d502cc3ca80 100644 > --- a/sound/soc/sof/intel/pci-tng.c > +++ b/sound/soc/sof/intel/pci-tng.c > @@ -75,7 +75,11 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev) > > /* LPE base */ > base = pci_resource_start(pci, desc->resindex_lpe_base) - IRAM_OFFSET; > - size = PCI_BAR_SIZE; > + size = pci_resource_len(pci, desc->resindex_lpe_base); > + if (size < PCI_BAR_SIZE) { > + dev_err(sdev->dev, "error: I/O region is too small.\n"); > + return -ENODEV; > + } May I ask how you found this issue? I am not clear on why there's a patch dedicated for a single device, but the same pattern in hda.c and in the HDaudio legacy driver exists. > > dev_dbg(sdev->dev, "LPE PHY base at 0x%x size 0x%x", base, size); > sdev->bar[DSP_BAR] = devm_ioremap(sdev->dev, base, size);