2008-11-06 13:50:17

by alok barsode

[permalink] [raw]
Subject: [PATCH] Netlink patch.

Hi Marcel,

Attaching a patch which implements a generic netlink command
GET_DEVLIST(HCIGETDEVLIST).

1. Will the netlink plugin expose an API like
int hci_get_devlist(struct hci_dev_list_req *dl) ?

2. If netlink registration fails would we fallback to raw sockets in the
plugin ?

Let me know if anything in the patch needs modification.

Thanks,
Alok.


Attachments:
0001-Adding-netlink-support-to-bluetooth.patch (5.86 kB)

2008-11-07 06:47:39

by alok barsode

[permalink] [raw]
Subject: [PATCH] Netlink patch.(modified)

Hi Marcel,

Attaching a modified netlink patch.
Forgot to free the buffer :) Thanks to ville for spotting it.

-Alok.


Attachments:
0001-Adding-netlink-support-to-bluetooth.patch (5.84 kB)

2008-11-06 14:44:39

by Ville Tervo

[permalink] [raw]
Subject: Re: [PATCH] Netlink patch.

Hi Alok,

ext Alok wrote:
> Hi Marcel,
>
> Attaching a patch which implements a generic netlink command
> GET_DEVLIST(HCIGETDEVLIST).

I don't know anything about netlink stuff but I'll give some generic comments :)


+
+ if (info->attrs[NLBLUETOOTH_ATTR_DEVNUM]) {
+ dev_num = nla_get_u16(info->attrs[NLBLUETOOTH_ATTR_DEVNUM]);
+ if (!dev_num)
+ return -EINVAL;
+ } else
+ return -EINVAL;
+

I would prefer this kind code paths. Easier to read.

if (!info->attrs[NLBLUETOOTH_ATTR_DEVNUM])
return -EINVAL;

dev_num = nla_get_u16(info->attrs[NLBLUETOOTH_ATTR_DEVNUM]);
if (!dev_num)
return -EINVAL;

+ msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+
+ if (!msg)
+ return -ENOBUFS;
+
+ hdr = genlmsg_put(msg, 0, info->snd_seq+1, &nlbluetooth_fam, 0, NLBLUETOOTH_CMD_GET_DEVLIST);
+
+ if (hdr == NULL)
+ return -ENOMEM;

Is msg left unfreed here?

+
+ nl_list = nla_nest_start(msg, NLBLUETOOTH_ATTR_DEVLIST);
+ if (!nl_list)
+ goto nla_put_failure;

And here? I cannot find skb_free or friends from genlmsg_cancel() path.


--
Ville