> The allocated array has 0 bytes. Any dereference is an error.

Well, then, that doesn't work either.

We -agree- we can't have this failing. You suggested (if I understood
correctly, which I doubt) that we set the pointer to NULL, and noted
that derefencing a NULL pointer would fail.  I agree such derefences
would fail, and tried to point out that this would be bad.  We can't
have pointer dereferences failing in the kernel ... duh.

Your reply seems like a non sequiter to me, pointing out that having
a pointer to an array of 0 bytes fails as well.  Ok - that's bad too.

So we cannot have a NULL pointer, used unchecked, and we cannot have
a non-NULL pointer to a zero byte array, used unchecked.

As I said, and as I thought Srinivasa coded, with these patch lines:

@@ -1772,6 +1779,9 @@ static ssize_t cpuset_tasks_read(struct 
 {
        struct ctr_struct *ctr = file->private_data;
 
+       if (!ctr->buf)     /* No tasks in this cpuset */
+               return 0;
+
        return simple_read_from_buffer(buf, nbytes, ppos, ctr->buf, ctr->bufsz);
 }

we actually have to check the NULL-ness (or emptiness) of this thing,
down where it would be used, to avoid using NULL or empty things.

Summary - Srinivasa's patch still looks ok to me.  This followup
discussion between you and I is just confusing me - sorry.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[EMAIL PROTECTED]> 1.925.600.0401
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to