return SI_ERR_FAILURE;
do {
+ dlerror(); /* clear */
/* locate the function we need to make the scsi inquries */
inst->sg_cmds_open_device_fn =
(sg_cmds_open_device_t)dlsym(handle, "sg_cmds_open_device");
- if (!inst->sg_cmds_open_device_fn)
+ if (dlerror())
break;
inst->sg_cmds_close_device_fn =
(sg_cmds_close_device_t)dlsym(handle, "sg_cmds_close_device");
- if (!inst->sg_cmds_close_device_fn)
+ if (dlerror())
break;
inst->sg_ll_inquiry_fn =
(sg_ll_inquiry_t)dlsym(handle, "sg_ll_inquiry");
- if (!inst->sg_ll_inquiry_fn)
+ if (dlerror())
break;
inst->sg_vpd_dev_id_iter_fn =
(sg_vpd_dev_id_iter_t)dlsym(handle, "sg_vpd_dev_id_iter");
- if (!inst->sg_vpd_dev_id_iter_fn)
+ if (dlerror())
break;
/* open the scsi/ata device */
if (length > SI_MAX_LEN)
break;
if (length > SI_DEFAULT_LEN) {
- rbuf = realloc(rbuf, length);
+ free(rbuf);
+ rbuf = malloc(length);
if (!rbuf) {
rc = SI_ERR_OUTOFMEM;
break;