kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: m.chetan.kumar@linux.intel.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: wwan: iosm: firmware flashing and coredump collection
Date: Wed, 15 Sep 2021 12:14:49 +0300	[thread overview]
Message-ID: <20210915091449.GA3747@kili> (raw)

Hello M Chetan Kumar,

The patch 13bb8429ca98: "net: wwan: iosm: firmware flashing and
coredump collection" from Sep 13, 2021, leads to the following
Smatch static checker warning:

	drivers/net/wwan/iosm/iosm_ipc_devlink.c:145 ipc_devlink_flash_update()
	warn: potential NULL parameter dereference 'params->component'

drivers/net/wwan/iosm/iosm_ipc_devlink.c
    131 static int ipc_devlink_flash_update(struct devlink *devlink,
    132                                     struct devlink_flash_update_params *params,
    133                                     struct netlink_ext_ack *extack)
    134 {
    135         struct iosm_devlink *ipc_devlink = devlink_priv(devlink);
    136         enum iosm_flash_comp_type fls_type;
    137         u32 rc = -EINVAL;
    138         u8 *mdm_rsp;
    139 
    140         mdm_rsp = kzalloc(IOSM_EBL_DW_PACK_SIZE, GFP_KERNEL);
    141         if (!mdm_rsp)
    142                 return -ENOMEM;
    143 
    144         fls_type = ipc_devlink_get_flash_comp_type(params->component,
--> 145                                                    strlen(params->component));

This function is called from devlink_nl_cmd_flash_update() and
params->component can be NULL so the strlen() will Oops.  Also it's
called from devlink_compat_flash_update() where params->component is
definitely NULL.

    146 
    147         switch (fls_type) {
    148         case FLASH_COMP_TYPE_PSI:
    149                 rc = ipc_flash_boot_psi(ipc_devlink, params->fw);
    150                 break;
    151         case FLASH_COMP_TYPE_EBL:
    152                 rc = ipc_flash_boot_ebl(ipc_devlink, params->fw);
    153                 if (!rc)
    154                         rc = ipc_flash_boot_set_capabilities(ipc_devlink,
    155                                                              mdm_rsp);
    156                 if (!rc)
    157                         rc = ipc_flash_read_swid(ipc_devlink, mdm_rsp);
    158                 break;
    159         case FLASH_COMP_TYPE_FLS:
    160                 rc = ipc_flash_send_fls(ipc_devlink, params->fw, mdm_rsp);
    161                 break;
    162         default:
    163                 devlink_flash_update_status_notify(devlink, "Invalid component",
    164                                                    params->component, 0, 0);
    165                 break;
    166         }
    167 
    168         if (!rc)
    169                 devlink_flash_update_status_notify(devlink, "Flashing success",
    170                                                    params->component, 0, 0);
    171         else
    172                 devlink_flash_update_status_notify(devlink, "Flashing failed",
    173                                                    params->component, 0, 0);
    174 
    175         kfree(mdm_rsp);
    176         return rc;
    177 }

regards,
dan carpenter

                 reply	other threads:[~2021-09-15  9:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210915091449.GA3747@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=m.chetan.kumar@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).