]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
Fixes to use dlerror() to test dlsym() calls and fixed possible
authorRoss Philipson <rossp@naboo.uk.xensource.com>
Fri, 1 May 2009 14:47:39 +0000 (14:47 +0000)
committerRoss Philipson <rossp@naboo.uk.xensource.com>
Fri, 1 May 2009 14:47:39 +0000 (14:47 +0000)
realloc() leak.

 Committer: Ross Philipson <rossp@naboo.uk.xensource.com>
  Changes to be committed:
modified:   libs/scsi/scsi_inq_stubs.c

libs/scsi/scsi_inq_stubs.c

index f55e6e6ed501e322b38758311f7bc90683449342..ba0e7756702ff3c95ac54f768bcfc7ed775938e3 100644 (file)
@@ -98,22 +98,23 @@ static int scsi_inq_open_device(struct sg_inst *inst, const char *device)
                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 */
@@ -195,7 +196,8 @@ static int scsi_do_vpd_inq(struct sg_inst *inst, struct scsi_inq_data *si_data,
                        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;