Subject: Re: [PATCH] ipv6: Fix possible NULL dereference in icmp6_dst_alloc

From: Jarek Poplawski <[email-masked]>
Date: Wed, 27 Jan 2010 13:28:52 +0000

On Wed, Jan 27, 2010 at 05:14:10AM -0800, David Miller wrote:
> From: Jarek Poplawski <[email-masked]>
> Date: Wed, 27 Jan 2010 12:43:31 +0000
> 
> > I'm only not sure there is a better way (comments?) to make this
> > code readable.
> 
> You can make it more readable and even validate the invariant at the
> same time by adding some kind of inline function if you wish.
> 
> static inline struct dst_entry *rtable_to_dst_entry(struct rtable *rt)
> {
> 	BUILD_BUG_ON(rt != &rt->u.dst);
> 
> 	/* Because "->u.dst" is the first member of struct rtable,
> 	 * this dereference is safe even when rt is NULL.
> 	 */
> 	return &rt->u.dst;
> }
> 
> Something like that.

Yes, it looks the most readable to me.

Thanks,
Jarek P.