diff mbox series

net: check the return value of ioremap() in mhz_mfc_config()

Message ID 20220802072826.3212612-1-studentxswpy@163.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: check the return value of ioremap() in mhz_mfc_config() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: linux@dominikbrodowski.net; 1 maintainers not CCed: linux@dominikbrodowski.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: Statements should start on a tabstop WARNING: please, no spaces at the start of a line WARNING: suspect code indent for conditional statements (4, 12)
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

studentxswpy@163.com Aug. 2, 2022, 7:28 a.m. UTC
From: Xie Shaowen <studentxswpy@163.com>

The function ioremap() in mhz_mfc_config() can fail, so
its return value should be checked.

Fixes: cdb138080b781 ("pcmcia: do not use win_req_t when calling pcmcia_request_window()")
Reported-by: Hacash Robot <hacashRobot@santino.com>
Signed-off-by: Xie Shaowen <studentxswpy@163.com>
---
 drivers/net/ethernet/smsc/smc91c92_cs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jakub Kicinski Aug. 4, 2022, 2:29 a.m. UTC | #1
On Tue,  2 Aug 2022 15:28:26 +0800 studentxswpy@163.com wrote:
> From: Xie Shaowen <studentxswpy@163.com>
> 
> The function ioremap() in mhz_mfc_config() can fail, so
> its return value should be checked.
> 
> Fixes: cdb138080b781 ("pcmcia: do not use win_req_t when calling pcmcia_request_window()")

The check seems fine, but that's not the commit which added the
ioremap() without checking the result. You need to find the fix 
commit in the git history where the bug exists, not just run
git blame on the line in question.

> Reported-by: Hacash Robot <hacashRobot@santino.com>
> Signed-off-by: Xie Shaowen <studentxswpy@163.com>
> ---
>  drivers/net/ethernet/smsc/smc91c92_cs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c
> index 37c822e27207..14333f5bdcdc 100644
> --- a/drivers/net/ethernet/smsc/smc91c92_cs.c
> +++ b/drivers/net/ethernet/smsc/smc91c92_cs.c
> @@ -446,6 +446,8 @@ static int mhz_mfc_config(struct pcmcia_device *link)
>  
>      smc->base = ioremap(link->resource[2]->start,
>  		    resource_size(link->resource[2]));
> +    if (!smc->base)
> +	    return -ENOMEM;
>      offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
>      i = pcmcia_map_mem_page(link, link->resource[2], offset);
>      if ((i == 0) &&
diff mbox series

Patch

diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c
index 37c822e27207..14333f5bdcdc 100644
--- a/drivers/net/ethernet/smsc/smc91c92_cs.c
+++ b/drivers/net/ethernet/smsc/smc91c92_cs.c
@@ -446,6 +446,8 @@  static int mhz_mfc_config(struct pcmcia_device *link)
 
     smc->base = ioremap(link->resource[2]->start,
 		    resource_size(link->resource[2]));
+    if (!smc->base)
+	    return -ENOMEM;
     offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
     i = pcmcia_map_mem_page(link, link->resource[2], offset);
     if ((i == 0) &&