lib/nvme: Add error handler for parse_event
Add handler for 'strstr, strrchr' function in 'NULL' return that maybe cause memory access issue. Signed-off-by: Weifeng Su <suweifeng1@huawei.com> Signed-off-by: Shihao Sun <sunshihao@huawei.com> Change-Id: I2525fbcd9f8ce0a78383305c735b2d27575f4bfe Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5071 Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
d73077b84a
commit
eacc9199fc
@ -135,10 +135,17 @@ parse_event(const char *buf, struct spdk_uevent *event)
|
||||
event->action = SPDK_NVME_UEVENT_REMOVE;
|
||||
}
|
||||
tmp = strstr(dev_path, "/uio/");
|
||||
|
||||
if (!tmp) {
|
||||
SPDK_ERRLOG("Invalid format of uevent: %s\n", dev_path);
|
||||
return -1;
|
||||
}
|
||||
memset(tmp, 0, SPDK_UEVENT_MSG_LEN - (tmp - dev_path));
|
||||
|
||||
pci_address = strrchr(dev_path, '/');
|
||||
if (!pci_address) {
|
||||
SPDK_ERRLOG("Not found NVMe BDF in uevent: %s\n", dev_path);
|
||||
return -1;
|
||||
}
|
||||
pci_address++;
|
||||
if (spdk_pci_addr_parse(&pci_addr, pci_address) != 0) {
|
||||
SPDK_ERRLOG("Invalid format for NVMe BDF: %s\n", pci_address);
|
||||
|
Loading…
Reference in New Issue
Block a user