Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752692Ab1BBGRg (ORCPT ); Wed, 2 Feb 2011 01:17:36 -0500 Received: from mgw2.diku.dk ([130.225.96.92]:55753 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752421Ab1BBGRe (ORCPT ); Wed, 2 Feb 2011 01:17:34 -0500 Date: Wed, 2 Feb 2011 07:17:29 +0100 (CET) From: Julia Lawall To: David Miller Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, paul.moore@hp.com, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] include/net/genetlink.h: Allow genlmsg_cancel to accept a NULL argument In-Reply-To: <20110201.145410.115936566.davem@davemloft.net> Message-ID: References: <20110201.145410.115936566.davem@davemloft.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2262 Lines: 64 On Tue, 1 Feb 2011, David Miller wrote: > From: Julia Lawall > Date: Fri, 28 Jan 2011 16:43:40 +0100 (CET) > > > nlmsg_cancel can accept NULL as its second argument, so for similarity, > > this patch extends genlmsg_cancel to be able to accept a NULL second > > argument as well. > > > > Signed-off-by: Julia Lawall > > I did a scan of all of the cases where this interface is used, and > I cannot find a situation where this capability would even be useful. > > The use pattern is always: > > hdr = genlmsg_put(skb, ...); > if (!hdr) > goto out; > > NLA_PUT_*(); > NLA_PUT_*(); > .... > > return genlmsg_end(skb, hdr); > > nla_put_failure: > genlmsg_cancel(skb, hdr); > out: > return -EWHATEVER; This pattern occurred in eg: net/netlabel/netlabel_unlabeled.c in the function netlbl_unlabel_staticlist_gen and in other netlabel code, as well as in net/wireless/nl80211.c, but with the function nl80211hdr_put instead of genlmsg_put. I submitted patches for all of these cases, so that is perhaps why you don't see them. But someone suggested to change genlmsg_cancel as well, to be as permissive as nlmsg_cancel. For nlmsg_cancel, there are two occurrences in net/netfilter/nf_conntrack_netlink.c where nlmsg_cancel is reachable with the second argument NULL. For nlmsg_cancel the ability to accept NULL as a second argument comes from the fact that it only calls nlmsg_trim, which does nothing if NULL is the second argument. nlmsg_trim is also called by nla_nest_cancel. There are many calls to nla_nest_cancel with NULL as the second argument in the directory net/sched, for example in the function gred_dump in net/sched/sch_gred.c. net/sched also contains a call to nlmsg_trim with NULL as the second argument, in the function flow_dump, in net/sched/cls_flow.c. The whole thing seems somewhat sloppy. I'm sure that all of the above-cited occurrences could be rewritten as outlined above to skip over the cancel/trim function. julia -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/