diff mbox

ocfs2: add the missing return value check of ocfs2_get_clusters

Message ID 51FA2702.5020903@huawei.com
State New, archived
Headers show

Commit Message

Joseph Qi Aug. 1, 2013, 9:14 a.m. UTC
In ocfs2_attach_refcount_tree() and ocfs2_duplicate_extent_list(), if
error occurs when calling ocfs2_get_clusters(), it will go with
unexpected behavior as local variables p_cluster, num_clusters and
ext_flags are declared without initialization.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
---
 fs/ocfs2/refcounttree.c |    8 ++++++++
 1 file changed, 8 insertions(+)

 			ret = ocfs2_add_refcount_flag(inode, &di_et,
@@ -4057,6 +4061,10 @@ static int ocfs2_duplicate_extent_list(struct
inode *s_inode,
 	while (cpos < clusters) {
 		ret = ocfs2_get_clusters(s_inode, cpos, &p_cluster,
 					 &num_clusters, &ext_flags);
+		if (ret) {
+			mlog_errno(ret);
+			goto out;
+		}

 		if (p_cluster) {
 			ret = ocfs2_add_refcounted_extent(t_inode, &et,

Comments

jeff.liu Aug. 1, 2013, 9:25 a.m. UTC | #1
On 08/01/2013 05:14 PM, Joseph Qi wrote:

> In ocfs2_attach_refcount_tree() and ocfs2_duplicate_extent_list(), if
> error occurs when calling ocfs2_get_clusters(), it will go with
> unexpected behavior as local variables p_cluster, num_clusters and
> ext_flags are declared without initialization.
> 
> Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
> ---
>  fs/ocfs2/refcounttree.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 998b17e..3589ec1 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -3886,6 +3886,10 @@ static int ocfs2_attach_refcount_tree(struct
> inode *inode,

Line wrapped?

>  	while (cpos < clusters) {
>  		ret = ocfs2_get_clusters(inode, cpos, &p_cluster,
>  					 &num_clusters, &ext_flags);
> +		if (ret) {
> +			mlog_errno(ret);
> +			goto unlock;
> +		}
> 
>  		if (p_cluster && !(ext_flags & OCFS2_EXT_REFCOUNTED)) {
>  			ret = ocfs2_add_refcount_flag(inode, &di_et,
> @@ -4057,6 +4061,10 @@ static int ocfs2_duplicate_extent_list(struct
> inode *s_inode,
>  	while (cpos < clusters) {
>  		ret = ocfs2_get_clusters(s_inode, cpos, &p_cluster,
>  					 &num_clusters, &ext_flags);
> +		if (ret) {
> +			mlog_errno(ret);
> +			goto out;
> +		}
> 
>  		if (p_cluster) {
>  			ret = ocfs2_add_refcounted_extent(t_inode, &et,
Joseph Qi Aug. 1, 2013, 9:30 a.m. UTC | #2
On 2013/8/1 17:25, Jeff Liu wrote:
> On 08/01/2013 05:14 PM, Joseph Qi wrote:
> 
>> In ocfs2_attach_refcount_tree() and ocfs2_duplicate_extent_list(), if
>> error occurs when calling ocfs2_get_clusters(), it will go with
>> unexpected behavior as local variables p_cluster, num_clusters and
>> ext_flags are declared without initialization.
>>
>> Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
>> ---
>>  fs/ocfs2/refcounttree.c |    8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
>> index 998b17e..3589ec1 100644
>> --- a/fs/ocfs2/refcounttree.c
>> +++ b/fs/ocfs2/refcounttree.c
>> @@ -3886,6 +3886,10 @@ static int ocfs2_attach_refcount_tree(struct
>> inode *inode,
> 
> Line wrapped?
> 
>>  	while (cpos < clusters) {
>>  		ret = ocfs2_get_clusters(inode, cpos, &p_cluster,
>>  					 &num_clusters, &ext_flags);
>> +		if (ret) {
>> +			mlog_errno(ret);
>> +			goto unlock;
>> +		}
>>
>>  		if (p_cluster && !(ext_flags & OCFS2_EXT_REFCOUNTED)) {
>>  			ret = ocfs2_add_refcount_flag(inode, &di_et,
>> @@ -4057,6 +4061,10 @@ static int ocfs2_duplicate_extent_list(struct
>> inode *s_inode,
>>  	while (cpos < clusters) {
>>  		ret = ocfs2_get_clusters(s_inode, cpos, &p_cluster,
>>  					 &num_clusters, &ext_flags);
>> +		if (ret) {
>> +			mlog_errno(ret);
>> +			goto out;
>> +		}
>>
>>  		if (p_cluster) {
>>  			ret = ocfs2_add_refcounted_extent(t_inode, &et,
> 
> 
> 

Sorry, I will resend it.
diff mbox

Patch

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 998b17e..3589ec1 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3886,6 +3886,10 @@  static int ocfs2_attach_refcount_tree(struct
inode *inode,
 	while (cpos < clusters) {
 		ret = ocfs2_get_clusters(inode, cpos, &p_cluster,
 					 &num_clusters, &ext_flags);
+		if (ret) {
+			mlog_errno(ret);
+			goto unlock;
+		}

 		if (p_cluster && !(ext_flags & OCFS2_EXT_REFCOUNTED)) {