login
Header Space

 
 

Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <sam@...>
Cc: <wg@...>, <oliver.hartkopp@...>, <socketcan-core@...>, <netdev@...>, <urs.thuermann@...>, <xemul@...>
Date: Saturday, April 26, 2008 - 3:03 am

From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 26 Apr 2008 08:40:07 +0200


I want to make one comment, directed at Wolfgang.

You are absolutely wrong, Wolfgang, in saying that Pavel's
original patch isn't easier to review than just changing
this code to go:

	if (copy_*_user())
		return -EFAULT;

In fact, recoding things like this is an immense extra hardship on a
reviewer.  I'll explain why.

If I see a patch that changes:

	err = SOMETHING;
	break;

into:

	err = SOMETHING_ELSE;
	break;

I know, WITH JUST READING THE PATCH, exactly what the side effects of
this change are.

I DO NOT need to bring the code into my editor and validate side
effects to the surrounding code.

I know that the assignment to 'err' is being changed, and that's it.

Whereas if you change:

	err = SOMETHING;
	break;

into:

	if (SOMETHING)
		return -SOME_ERROR;
	break;

I now have to bring the code into an editor and make sure that the
control flow change doesn't break things.

For example, maybe the exit of the switch statement was important, to
make sure cleanup code runs at the end of the function to release
locks, free allocated memory, etc.

With Pavel's patch it is not necessary to make such validations so
it's INFINITELY easier to validate.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH][CAN]: Fix copy_from_user() results interpretation., Pavel Emelyanov, (Fri Apr 25, 8:42 am)
Re: [PATCH][CAN]: Fix copy_from_user() results interpretation., Wolfgang Grandegger, (Sat Apr 26, 2:19 am)
Re: [PATCH][CAN]: Fix copy_from_user() results interpretation., David Miller, (Sat Apr 26, 3:03 am)
Re: [PATCH][CAN]: Fix copy_from_user() results interpretation., Wolfgang Grandegger, (Sat Apr 26, 9:04 am)
Re: [PATCH][CAN]: Fix copy_from_user() results interpretation., Wolfgang Grandegger, (Sat Apr 26, 2:35 am)
speck-geostationary