]> www.infradead.org Git - users/sagi/nvme-cli.git/commit
nvme-cli: fix get_nsid() return value check
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Thu, 3 May 2018 10:04:45 +0000 (06:04 -0400)
committerKeith Busch <keith.busch@intel.com>
Thu, 3 May 2018 14:29:10 +0000 (08:29 -0600)
commit1b7a0ed435af4a14dbc9d6fd2a6d80ad803c0d5f
tree67ddc1ee74223ca26014c9904e57f29251bde848
parentdf9504d2907e3a4b560814cfe6781e40dd56f3ed
nvme-cli: fix get_nsid() return value check

All the callers of the get_nsid() defined cfg.namespace_id as __u32.
The true return value of the call:-

cfg.namespace_id = get_nsid()

will not be used in case nvme_get_nsid() returns < 0 and
comparion of

if (cfg.namespace_id <= 0)

and will result is cfg.namespace_id > 0 due to type mismatch.

We fix this scenario by returning the 0 (invalid nsid on get_nsid()
for nvme_get_nsid() failure case) and adding

cfg.namespace_id == 0

for error checking in all the callers of the get_nsid().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme.c