Skip to contentSkip to conversation

nf_conntrack_amanda: fix textsearch_prepare() error check

PATCH In review Akinobu Mita 2 participants 2 messages Jun 3, 2007 – Jun 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nf_conntrack_amanda: fix textsearch_prepare() error check

The return value from textsearch_prepare() needs to be checked by IS_ERR(). Because it returns error code as a pointer.

Cc "Brian J. Murrell" <[email protected]>
---
 net/netfilter/nf_conntrack_amanda.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_amanda.c +6 -6
Index: 2.6-mm/net/netfilter/nf_conntrack_amanda.c
===================================================================
@@ -208,13 +208,14 @@ static int __init nf_conntrack_amanda_in
 {
 	int ret, i;
 
-	ret = -ENOMEM;
 	for (i = 0; i < ARRAY_SIZE(search); i++) {
 		search[i].ts = textsearch_prepare(ts_algo, search[i].string,
 						  search[i].len,
 						  GFP_KERNEL, TS_AUTOLOAD);
-		if (search[i].ts == NULL)
+		if (IS_ERR(search[i].ts)) {
+			ret = PTR_ERR(search[i].ts);
 			goto err1;
+		}
 	}
 	ret = nf_conntrack_helper_register(&amanda_helper[0]);
 	if (ret < 0)
@@ -227,10 +228,9 @@ static int __init nf_conntrack_amanda_in
 err2:
 	nf_conntrack_helper_unregister(&amanda_helper[0]);
 err1:
-	for (; i >= 0; i--) {
-		if (search[i].ts)
-			textsearch_destroy(search[i].ts);
-	}
+	while (--i >= 0)
+		textsearch_destroy(search[i].ts);
+
 	return ret;
 }
 
#1 lore raw
Quoted 2 lines · Akinobu Mita

The return value from textsearch_prepare() needs to be checked by IS_ERR(). Because it returns error code as a pointer.

Good catch, applied. Thanks Akinobu.