Re: [PATCH] cgroup:be able to remove the record of unplugged device

From: Paul Menage
Date: Mon Jul 25 2011 - 16:45:33 EST


On Sun, Jul 24, 2011 at 11:03 PM, Wanlong Gao <gaowanlong@xxxxxxxxxxxxxx> wrote:
> @@ -826,15 +826,15 @@ static int blkio_policy_parse_and_set(char *buf,
>
>        dev = MKDEV(major, minor);
>
> +       if (s[1] == NULL)
> +               return -EINVAL;
> +

How can s[1] be NULL? If there aren't two parameters in the input we'd
have returned earlier since i!=2, and each element in s[] is
initialized from a pointer that has been dereference immediately
beforehand, and hence can't be NULL.

>        ret = blkio_check_dev_num(dev);
> -       if (ret)
> +       if (ret && (strcmp(s[1], "0\0")))
>                return ret;

Better to move the parsing of s[1] ahead of this, and do a numerical
comparison? Otherwise this will miss the case where the input string
is e.g. "8:0 00"

Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/