From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbcDSLgZ (ORCPT ); Tue, 19 Apr 2016 07:36:25 -0400 Received: from mga02.intel.com ([134.134.136.20]:26222 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752285AbcDSLgY (ORCPT ); Tue, 19 Apr 2016 07:36:24 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,506,1455004800"; d="scan'208";a="787857680" Subject: Re: [PATCH 1/7] mmc: sdhci-pltfm: bail out if register resource is too small To: Masahiro Yamada , linux-mmc@vger.kernel.org References: <1460600990-10993-1-git-send-email-yamada.masahiro@socionext.com> <1460600990-10993-2-git-send-email-yamada.masahiro@socionext.com> Cc: linux-kernel@vger.kernel.org, Ulf Hansson From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <57161754.5050303@intel.com> Date: Tue, 19 Apr 2016 14:32:36 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1460600990-10993-2-git-send-email-yamada.masahiro@socionext.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/04/16 05:29, Masahiro Yamada wrote: > This code checks the resource size and displays an error message if > it is too small, but still moves forward. Let is fail in that case. is -> it How do you know there aren't drivers that actually have a smaller size? One that might not is sdhci-dove which appears to sidestep some registers in sdhci_dove_readw(). > > Signed-off-by: Masahiro Yamada > --- > > drivers/mmc/host/sdhci-pltfm.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c > index 072bb27..7d12203 100644 > --- a/drivers/mmc/host/sdhci-pltfm.c > +++ b/drivers/mmc/host/sdhci-pltfm.c > @@ -127,8 +127,11 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, > goto err; > } > > - if (resource_size(iomem) < 0x100) > + if (resource_size(iomem) < 0x100) { > dev_err(&pdev->dev, "Invalid iomem size!\n"); > + ret = -EINVAL; > + goto err; > + } > > host = sdhci_alloc_host(&pdev->dev, > sizeof(struct sdhci_pltfm_host) + priv_size); >