On Thu, Aug 14, 2008 at 12:04:50PM +0200, Sven Wegener wrote:
> On Thu, 14 Aug 2008, Julius Volz wrote:
>
> > On Wed, Aug 13, 2008 at 11:51:06PM +0200, Sven Wegener wrote:
> > > On Fri, 8 Aug 2008, Julius Volz wrote:
> > > > +static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info
> > > > *info)
> > > > +{
> > > > + struct sk_buff *msg;
> > > > + void *reply;
> > > > + int ret, cmd, reply_cmd;
> > > > +
> > > > + mutex_lock(&__ip_vs_mutex);
> > > > +
> > > > + cmd = info->genlhdr->cmd;
> > > > +
> > > > + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
> > > > + if (!msg) {
> > > > + ret = -ENOMEM;
> > > > + goto out_err;
> > >
> > > Here you want out...
> > >
> > > > + }
> > > > +
> > > > + if (cmd == IPVS_CMD_GET_SERVICE)
> > > > + reply_cmd = IPVS_CMD_NEW_SERVICE;
> > > > + else if (cmd == IPVS_CMD_GET_INFO)
> > > > + reply_cmd = IPVS_CMD_SET_INFO;
> > > > + else if (cmd == IPVS_CMD_GET_CONFIG)
> > > > + reply_cmd = IPVS_CMD_SET_CONFIG;
> > > > + else {
> > > > + IP_VS_ERR("unknown Generic Netlink command\n");
> > > > + ret = -EINVAL;
> > > > + goto out;
> > >
> > > ..and here you want out_error, to not leak msg.
> >
> > Ouch, thanks! Fixed this and locked the mutex later. I also removed the
> > "if (msg)" from out_err, as it becomes unneeded now. Here's the updated
> > patch:
>
> You missed the static on the register and unregister functions down at the
> bottom. :) Also see my comments to your change regarding the above issue
> down here.
Hrm, yes!
> > +static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
> > +{
> > + struct sk_buff *msg;
> > + void *reply;
> > + int ret, cmd, reply_cmd;
> > +
> > + cmd = info->genlhdr->cmd;
> > +
> > + if (cmd == IPVS_CMD_GET_SERVICE)
> > + reply_cmd = IPVS_CMD_NEW_SERVICE;
> > + else if (cmd == IPVS_CMD_GET_INFO)
> > + reply_cmd = IPVS_CMD_SET_INFO;
> > + else if (cmd == IPVS_CMD_GET_CONFIG)
> > + reply_cmd = IPVS_CMD_SET_CONFIG;
> > + else {
> > + IP_VS_ERR("unknown Generic Netlink command\n");
> > + ret = -EINVAL;
> > + goto out;
> > + }
> > +
> > + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
> > + if (!msg) {
> > + ret = -ENOMEM;
> > + goto out;
> > + }
> > +
> > + reply = genlmsg_put_reply(msg, info, &ip_vs_genl_family, 0, reply_cmd);
> > + if (reply == NULL)
> > + goto nla_put_failure;
>
> These gotos now unlock a not locked mutex down in the error path.
What did they put into my water supply :-/ Thanks!
>
> > +
> > + mutex_lock(&__ip_vs_mutex);
>
> Is there a reason not using mutex_lock_interruptible() like the sockopt
> interface does? I wondered in your earlier patch, but didn't really
> bother.
Not an expert here. I saw mutex_lock_interruptible() being used in the
old sockopt interface, but returning -ERESTARTSYS on interruption. Can I
do something similar to this from a genetlink function or what is the
right way? I was unsure, so I stuck to mutex_lock()...
Julius
--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
|