media: cec-core: fix a bug at cec_error_inj_write()
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 23 Mar 2018 11:51:07 +0000 (07:51 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 23 Mar 2018 12:37:22 +0000 (08:37 -0400)
If the adapter doesn't have error_inj_parse_line() ops, the
write() logic won't return -EINVAL, but, instead, it will keep
looping, because "count" is a non-negative number.

Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/cec/cec-core.c

index ea3eccfdba15080efb5e79df8ccf4981348adbd5..b0c87f9ea08fcf07c54bbdc859209e84de62f7e0 100644 (file)
@@ -209,14 +209,14 @@ static ssize_t cec_error_inj_write(struct file *file,
        if (IS_ERR(buf))
                return PTR_ERR(buf);
        p = buf;
-       while (p && *p && count >= 0) {
+       while (p && *p) {
                p = skip_spaces(p);
                line = strsep(&p, "\n");
                if (!*line || *line == '#')
                        continue;
                if (!adap->ops->error_inj_parse_line(adap, line)) {
-                       count = -EINVAL;
-                       break;
+                       kfree(buf);
+                       return -EINVAL;
                }
        }
        kfree(buf);