[dm-devel] [PATCH 1/5] Fix potential null pointer dereference
lixiaokeng
lixiaokeng at huawei.com
Thu Nov 18 02:04:08 UTC 2021
>> @@ -388,8 +388,10 @@ sysfs_get_tgt_nodename(struct path *pp, char *node)
>> if (value && !strcmp(value, "usb")) {
>> pp->sg_id.proto_id = SCSI_PROTOCOL_USB;
>> tgtname = udev_device_get_sysname(tgtdev);
>> - strlcpy(node, tgtname, NODE_NAME_SIZE);
>> - return 0;
>> + if (!tgtname) {
>
> I assume that you mean "if (tgtname)"
>
Thanks for your correction. I'm will correct it.
>> + strlcpy(node, tgtname, NODE_NAME_SIZE);
>> + return 0;
>> + }
>> }
>> tgtdev = udev_device_get_parent(tgtdev);
>> }
>> diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
>> index d40c0869..f778410a 100644
>> --- a/libmultipath/foreign/nvme.c
>> +++ b/libmultipath/foreign/nvme.c
>> @@ -184,7 +184,9 @@ static int snprint_nvme_map(const struct gen_multipath *gmp,
>> "firmware_rev"));
>> case 'r':
>> val = udev_device_get_sysattr_value(nvm->udev, "ro");
>> - if (val[0] == 1)
>> + if (!val)
>> + return -1;
>
> sprint_ro() returns "undef" for a similar case. Perhaps we should do
> that here as well.
>
I'll do it here and send v2 patch. Thanks again.
Regards,
Lixiaokeng
More information about the dm-devel
mailing list