[Gluster-devel] Fwd: New Defects reported by Coverity Scan for GlusterFS

Lalatendu Mohanty lmohanty at redhat.com
Mon May 19 07:35:23 UTC 2014


FYI,

Guideline for fixing Coverity issues :
http://www.gluster.org/community/documentation/index.php/Fixing_Issues_Reported_By_Tools_For_Static_Code_Analysis#Coverity

Thanks,
Lala

-------- Original Message --------
Subject: 	New Defects reported by Coverity Scan for GlusterFS
Date: 	Mon, 19 May 2014 00:10:53 -0700
From: 	scan-admin at coverity.com



Hi,


Please find the latest report on new defect(s) introduced to GlusterFS found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 20 of 29 defect(s)


** CID 1214626:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 12383 in glusterd_recursive_rmdir()
/xlators/mgmt/glusterd/src/glusterd-utils.c: 12383 in glusterd_recursive_rmdir()

** CID 1214625:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 1013 in glusterd_get_brick_mount_dir()
/xlators/mgmt/glusterd/src/glusterd-utils.c: 1013 in glusterd_get_brick_mount_dir()

** CID 1214624:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 7108 in glusterd_get_brick_mount_device()
/xlators/mgmt/glusterd/src/glusterd-utils.c: 7108 in glusterd_get_brick_mount_device()

** CID 1214615:  Data race condition  (MISSING_LOCK)
/xlators/storage/posix/src/posix.c: 5662 in init()

** CID 1214616:  Unsigned compared against 0  (NO_EFFECT)
/rpc/rpc-lib/src/rpcsvc.c: 133 in rpcsvc_get_program_vector_sizer()

** CID 1214618:  Dereference null return value  (NULL_RETURNS)
/xlators/storage/posix/src/posix.c: 3119 in posix_links_in_same_directory()

** CID 1214617:  Dereference null return value  (NULL_RETURNS)
/api/src/glfs-mgmt.c: 380 in glfs_get_volume_info()

** CID 1124684:  Dereference null return value  (NULL_RETURNS)
/libglusterfs/src/syncop.c: 1038 in entry_copy()

** CID 1214608:  Wrong operator used  (CONSTANT_EXPRESSION_RESULT)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 1081 in __server_get_volume_info()

** CID 1214612:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4419 in glusterd_snapshot_activate_commit()

** CID 1214611:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4480 in glusterd_snapshot_deactivate_commit()

** CID 1214610:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4113 in glusterd_snapshot_activate_deactivate_prevalidate()

** CID 1214609:  Logically dead code  (DEADCODE)
/xlators/features/changelog/lib/src/gf-history-changelog.c: 910 in gf_history_changelog()

** CID 1214613:  Dereference after null check  (FORWARD_NULL)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4149 in glusterd_snapshot_activate_deactivate_prevalidate()

** CID 1214614:  Overflowed return value  (INTEGER_OVERFLOW)
/xlators/mgmt/glusterd/src/glusterd-geo-rep.c: 2854 in gd_pause_or_resume_gsync()

** CID 1214623:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 1130 in __server_get_volume_info()

** CID 1214622:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 410 in glusterd_create_missed_snap()

** CID 1214621:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 3618 in glusterd_take_lvm_snapshot()

** CID 1214620:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-op-sm.c: 3634 in glusterd_op_start_rb_timer()

** CID 1214619:  Resource leak  (RESOURCE_LEAK)
/xlators/features/changelog/src/changelog-helpers.c: 313 in htime_open()


________________________________________________________________________________________________________
*** CID 1214626:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 12383 in glusterd_recursive_rmdir()
12377             if (ret) {
12378                     gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s",
12379                             delete_path, strerror (errno));
12380             }
12381
12382     out:
>>>     CID 1214626:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "dir" going out of scope leaks the storage it points to.
12383             return ret;
12384     }
12385
12386     gf_boolean_t
12387     glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
12388                                       int down_count, gf_boolean_t first_brick_on,
/xlators/mgmt/glusterd/src/glusterd-utils.c: 12383 in glusterd_recursive_rmdir()
12377             if (ret) {
12378                     gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s",
12379                             delete_path, strerror (errno));
12380             }
12381
12382     out:
>>>     CID 1214626:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "dir" going out of scope leaks the storage it points to.
12383             return ret;
12384     }
12385
12386     gf_boolean_t
12387     glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
12388                                       int down_count, gf_boolean_t first_brick_on,

________________________________________________________________________________________________________
*** CID 1214625:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 1013 in glusterd_get_brick_mount_dir()
1007
1008                     snprintf (mount_dir, PATH_MAX, "/%s", brick_dir);
1009             }
1010
1011     out:
1012             gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
>>>     CID 1214625:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "mnt_pt" going out of scope leaks the storage it points to.
1013             return ret;
1014     }
1015
1016     int32_t
1017     glusterd_brickinfo_new_from_brick (char *brick,
1018                                        glusterd_brickinfo_t **brickinfo)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 1013 in glusterd_get_brick_mount_dir()
1007
1008                     snprintf (mount_dir, PATH_MAX, "/%s", brick_dir);
1009             }
1010
1011     out:
1012             gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
>>>     CID 1214625:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "mnt_pt" going out of scope leaks the storage it points to.
1013             return ret;
1014     }
1015
1016     int32_t
1017     glusterd_brickinfo_new_from_brick (char *brick,
1018                                        glusterd_brickinfo_t **brickinfo)

________________________________________________________________________________________________________
*** CID 1214624:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-utils.c: 7108 in glusterd_get_brick_mount_device()
7102             }
7103
7104             /* get the fs_name/device */
7105             device = gf_strdup (entry->mnt_fsname);
7106
7107     out:
>>>     CID 1214624:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "mnt_pt" going out of scope leaks the storage it points to.
7108             return device;
7109     }
7110
7111     int
7112     glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo,
7113                                        glusterd_brickinfo_t *brickinfo,
/xlators/mgmt/glusterd/src/glusterd-utils.c: 7108 in glusterd_get_brick_mount_device()
7102             }
7103
7104             /* get the fs_name/device */
7105             device = gf_strdup (entry->mnt_fsname);
7106
7107     out:
>>>     CID 1214624:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "mnt_pt" going out of scope leaks the storage it points to.
7108             return device;
7109     }
7110
7111     int
7112     glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo,
7113                                        glusterd_brickinfo_t *brickinfo,

________________________________________________________________________________________________________
*** CID 1214615:  Data race condition  (MISSING_LOCK)
/xlators/storage/posix/src/posix.c: 5662 in init()
5656                 (uuid_is_null (_private->glusterd_uuid))) {
5657                             gf_log (this->name, GF_LOG_INFO,
5658                                     "glusterd uuid is NULL, pathinfo xattr would"
5659                                     " fallback to <hostname>:<export>");
5660             }
5661
>>>     CID 1214615:  Data race condition  (MISSING_LOCK)
>>>     Accessing "_private->health_check_active" without holding lock "posix_private.lock". Elsewhere, "_private->health_check_active" is accessed with "posix_private.lock" held 4 out of 5 times.
5662             _private->health_check_active = _gf_false;
5663             GF_OPTION_INIT ("health-check-interval",
5664                             _private->health_check_interval, uint32, out);
5665             if (_private->health_check_interval)
5666                     posix_spawn_health_check_thread (this);
5667

________________________________________________________________________________________________________
*** CID 1214616:  Unsigned compared against 0  (NO_EFFECT)
/rpc/rpc-lib/src/rpcsvc.c: 133 in rpcsvc_get_program_vector_sizer()
127                     }
128             }
129             pthread_mutex_unlock (&svc->rpclock);
130
131             if (found) {
132                     /* Make sure the requested procnum is supported by RPC prog */
>>>     CID 1214616:  Unsigned compared against 0  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "procnum < 0U".
133                     if ((procnum < 0) || (procnum >= program->numactors)) {
134                             gf_log (GF_RPCSVC, GF_LOG_ERROR,
135                                     "RPC procedure %d not available for Program %s",
136                                     procnum, program->progname);
137                             return NULL;
138                     }

________________________________________________________________________________________________________
*** CID 1214618:  Dereference null return value  (NULL_RETURNS)
/xlators/storage/posix/src/posix.c: 3119 in posix_links_in_same_directory()
3113
3114                             strcpy (temppath, dirpath);
3115                             strcat (temppath, "/");
3116                             strcat (temppath, entry->d_name);
3117
3118                             gf_entry = gf_dirent_for_name (entry->d_name);
>>>     CID 1214618:  Dereference null return value  (NULL_RETURNS)
>>>     Dereferencing a null pointer "gf_entry".
3119                             gf_entry->inode = inode_ref (leaf_inode);
3120                             gf_entry->dict
3121                                     = posix_lookup_xattr_fill (this,
3122                                                                temppath,
3123                                                                &loc, xdata,
3124                                                                NULL);

________________________________________________________________________________________________________
*** CID 1214617:  Dereference null return value  (NULL_RETURNS)
/api/src/glfs-mgmt.c: 380 in glfs_get_volume_info()
374             glusterfs_ctx_t  *ctx   = NULL;
375             struct syncargs  args   = {0, };
376             int              ret    = 0;
377
378             ctx = fs->ctx;
379             frame = create_frame (THIS, ctx->pool);
>>>     CID 1214617:  Dereference null return value  (NULL_RETURNS)
>>>     Dereferencing a null pointer "frame".
380             frame->local = &args;
381
382             __yawn ((&args));
383
384             ret = glfs_get_volume_info_rpc (frame, THIS, fs);
385             if (ret)

________________________________________________________________________________________________________
*** CID 1124684:  Dereference null return value  (NULL_RETURNS)
/libglusterfs/src/syncop.c: 1038 in entry_copy()
1032     entry_copy (gf_dirent_t *source)
1033     {
1034             gf_dirent_t *sink = NULL;
1035
1036             sink = gf_dirent_for_name (source->d_name);
1037
>>>     CID 1124684:  Dereference null return value  (NULL_RETURNS)
>>>     Dereferencing a null pointer "sink".
1038             sink->d_off = source->d_off;
1039             sink->d_ino = source->d_ino;
1040             sink->d_type = source->d_type;
1041             sink->d_stat = source->d_stat;
1042
1043     	if (source->inode)

________________________________________________________________________________________________________
*** CID 1214608:  Wrong operator used  (CONSTANT_EXPRESSION_RESULT)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 1081 in __server_get_volume_info()
1075             if (ret) {
1076                     op_errno = EINVAL;
1077                     ret = -1;
1078                     goto out;
1079             }
1080
>>>     CID 1214608:  Wrong operator used  (CONSTANT_EXPRESSION_RESULT)
>>>     "flags | 1 /* (int32_t)GF_GET_VOLUME_UUID */" is always 1/true regardless of the values of its operand. This occurs as the logical operand of if. Did you intend to use '&' rather than '|'?
1081             if (flags | (int32_t)GF_GET_VOLUME_UUID) {
1082                     volume_id_str = gf_strdup (uuid_utoa (volinfo->volume_id));
1083                     if (!volume_id_str) {
1084                             op_errno = ENOMEM;
1085                             ret = -1;
1086                             goto out;

________________________________________________________________________________________________________
*** CID 1214612:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4419 in glusterd_snapshot_activate_commit()
4413             * Change this when multiple volume snapshot is introduced
4414             */
4415             snap_volinfo = list_entry (snap->volumes.next, glusterd_volinfo_t,
4416                             vol_list);
4417             if (!snap_volinfo) {
4418                             gf_log (this->name, GF_LOG_ERROR,
>>>     CID 1214612:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement "do  {
   do  {
     if (0)
   ...".
4419                                     "Unable to fetch snap_volinfo");
4420                             ret = -1;
4421                             goto out;
4422             }
4423
4424             ret = glusterd_start_volume (snap_volinfo, flags, _gf_true);

________________________________________________________________________________________________________
*** CID 1214611:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4480 in glusterd_snapshot_deactivate_commit()
4474             * Change this when multiple volume snapshot is introduced
4475             */
4476             snap_volinfo = list_entry (snap->volumes.next, glusterd_volinfo_t,
4477                             vol_list);
4478             if (!snap_volinfo) {
4479                             gf_log (this->name, GF_LOG_ERROR,
>>>     CID 1214611:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement "do  {
   do  {
     if (0)
   ...".
4480                                     "Unable to fetch snap_volinfo");
4481                             ret = -1;
4482                             goto out;
4483             }
4484
4485             ret = glusterd_stop_volume (snap_volinfo);

________________________________________________________________________________________________________
*** CID 1214610:  Logically dead code  (DEADCODE)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4113 in glusterd_snapshot_activate_deactivate_prevalidate()
4107             * Change this when multiple volume snapshot is introduced
4108             */
4109             snap_volinfo = list_entry (snap->volumes.next, glusterd_volinfo_t,
4110                             vol_list);
4111             if (!snap_volinfo) {
4112                     gf_log (this->name, GF_LOG_ERROR,
>>>     CID 1214610:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement "do  {
   do  {
     if (0)
   ...".
4113                             "Unable to fetch snap_volinfo");
4114                     ret = -1;
4115                     goto out;
4116             }
4117
4118             /*TODO: When multiple snapvolume are involved a cummulative

________________________________________________________________________________________________________
*** CID 1214609:  Logically dead code  (DEADCODE)
/xlators/features/changelog/lib/src/gf-history-changelog.c: 910 in gf_history_changelog()
904                             goto out;
905
906                     } /* end of range check */
907
908             } /* end of readdir() */
909
>>>     CID 1214609:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this expression "to" inside statement "if (!from || !to)
   ret = -1;".
910             if (!from || !to)
911                     ret = -1;
912
913     out:
914             if (dirp != NULL)
915                     closedir (dirp);

________________________________________________________________________________________________________
*** CID 1214613:  Dereference after null check  (FORWARD_NULL)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 4149 in glusterd_snapshot_activate_deactivate_prevalidate()
4143             }
4144             ret = 0;
4145     out:
4146
4147             if (ret && err_str[0] != '\0') {
4148                     gf_log (this->name, loglevel, "%s", err_str);
>>>     CID 1214613:  Dereference after null check  (FORWARD_NULL)
>>>     Dereferencing null pointer "op_errstr".
4149                     *op_errstr = gf_strdup (err_str);
4150             }
4151
4152             return ret;
4153     }
4154

________________________________________________________________________________________________________
*** CID 1214614:  Overflowed return value  (INTEGER_OVERFLOW)
/xlators/mgmt/glusterd/src/glusterd-geo-rep.c: 2854 in gd_pause_or_resume_gsync()
2848                     }
2849             }
2850             ret = 0;
2851
2852     out:
2853             sys_close (pfd);
>>>     CID 1214614:  Overflowed return value  (INTEGER_OVERFLOW)
>>>     Overflowed or truncated value (or a value computed from an overflowed or truncated value) "ret" used as return value.
2854             return ret;
2855     }
2856
2857     static int
2858     stop_gsync (char *master, char *slave, char **msg,
2859                 char *conf_path, char **op_errstr,

________________________________________________________________________________________________________
*** CID 1214623:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 1130 in __server_get_volume_info()
1124                     dict_unref (dict_rsp);
1125             }
1126
1127             if (vol_info_rsp.dict.dict_val) {
1128                     GF_FREE (vol_info_rsp.dict.dict_val);
1129             }
>>>     CID 1214623:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "volume_id_str" going out of scope leaks the storage it points to.
1130             return ret;
1131     }
1132
1133     int
1134     server_get_volume_info (rpcsvc_request_t *req)
1135     {

________________________________________________________________________________________________________
*** CID 1214622:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-handshake.c: 410 in glusterd_create_missed_snap()
404                             "brick %s:%s failed", brickinfo->hostname,
405                             snap_opinfo->brick_path);
406                     ret = -1;
407                     goto out;
408             }
409
>>>     CID 1214622:  Resource leak  (RESOURCE_LEAK)
>>>     Overwriting "device" in "device = glusterd_build_snap_device_path(device, snap_vol->volname, snap_opinfo->brick_num - 1)" leaks the storage that "device" points to.
410             device = glusterd_build_snap_device_path (device, snap_vol->volname,
411                                                       snap_opinfo->brick_num - 1);
412             if (!device) {
413                     gf_log (this->name, GF_LOG_ERROR, "cannot copy the snapshot "
414                             "device name (volname: %s, snapname: %s)",
415                              snap_vol->volname, snap->snapname);

________________________________________________________________________________________________________
*** CID 1214621:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-snapshot.c: 3618 in glusterd_take_lvm_snapshot()
3612                     gf_log (this->name, GF_LOG_ERROR, "taking snapshot of the "
3613                             "brick (%s) of device %s failed",
3614                             origin_brick_path, origin_device);
3615             }
3616
3617     out:
>>>     CID 1214621:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "origin_device" going out of scope leaks the storage it points to.
3618             return ret;
3619     }
3620
3621     int32_t
3622     glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
3623                                 glusterd_brickinfo_t *brickinfo,

________________________________________________________________________________________________________
*** CID 1214620:  Resource leak  (RESOURCE_LEAK)
/xlators/mgmt/glusterd/src/glusterd-op-sm.c: 3634 in glusterd_op_start_rb_timer()
3628                                                glusterd_do_replace_brick,
3629                                                (void *) rb_ctx);
3630
3631             ret = 0;
3632
3633     out:
>>>     CID 1214620:  Resource leak  (RESOURCE_LEAK)
>>>     Variable "rb_txn_id" going out of scope leaks the storage it points to.
3634             return ret;
3635     }
3636
3637     /* This function takes a dict and converts the uuid values of key specified
3638      * into hostnames
3639      */

________________________________________________________________________________________________________
*** CID 1214619:  Resource leak  (RESOURCE_LEAK)
/xlators/features/changelog/src/changelog-helpers.c: 313 in htime_open()
307             /* save this htime_fd in priv->htime_fd */
308             priv->htime_fd = fd;
309             /* initialize rollover-number in priv to 1 */
310             priv->rollover_count = 1;
311
312     out:
>>>     CID 1214619:  Resource leak  (RESOURCE_LEAK)
>>>     Handle variable "fd" going out of scope leaks the handle.
313             return ret;
314     }
315
316     int
317     changelog_open (xlator_t *this,
318                     changelog_priv_t *priv)


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/987?tab=overview

To unsubscribe from the email notification for new defects, http://scan5.coverity.com/cgi-bin/unsubscribe.py





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://supercolony.gluster.org/pipermail/gluster-devel/attachments/20140519/4b640464/attachment-0002.html>


More information about the Gluster-devel mailing list