IRDA: Fix genlmsg_put() return value check.
Subsystems (2)
PATCH 1/1 IRDA: Fix genlmsg_put() return value check.
Fix an incorrect return value check of genlmsg_put() in irda_nl_get_mode(). genlmsg_put() does not use ERR_PTR() to encode return values, it just returns NULL on error.
--- net/irda/irnetlink.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/irda/irnetlink.c +2 -2
@@ -101,8 +101,8 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) hdr =genlmsg_put (msg, info->snd_pid, info->snd_seq, &irda_nl_family,0 ,IRDA_NL_CMD_GET_MODE ); -if (IS_ERR (hdr)) { - ret =PTR_ERR (hdr); +if (hdr ==NULL ) { + ret = -ENOMEM ; goto err_out; }
Signature · 1 line
1.5.3.6
Quoted 14 lines · Julius Volz
Fix an incorrect return value check of
genlmsg_put()inirda_nl_get_mode().genlmsg_put()does not useERR_PTR()to encode return values, it just returns NULL on error.Signed-off-by Julius Volz <[email protected]>--- net/irda/irnetlink.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)net/irda/irnetlink.c +0
-0
net/irda/irnetlink.c static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) · line 107
Quoted 9 lines
net/irda/irnetlink.c +2
-2@@ -101,8 +101,8 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) hdr =genlmsg_put (msg, info->snd_pid, info->snd_seq, &irda_nl_family,0 ,IRDA_NL_CMD_GET_MODE ); -if (IS_ERR (hdr)) { - ret =PTR_ERR (hdr); +if (hdr ==NULL ) { + ret = -ENOMEM ; goto err_out; }
Good catch, but the correct return value for insufficient space in the skb is -ENOSPC.
On Mon, 23 Jun 2008 21:43:31 +0200, Patrick McHardy <[email protected]>
Quoted 50 lines · wrote:
Quoted 1 line · Julius Volz
Fix an incorrect return value check of
genlmsg_put()in
irda_nl_get_mode().net/irda/irnetlink.c static int irda_nl_get_mode(struct sk_buff *skb,
Quoted 25 lines
genlmsg_put()does not useERR_PTR()to encode return values, it justreturns NULL on error.
Signed-off-by Julius Volz <[email protected]>---
net/irda/irnetlink.c | 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)net/irda/irnetlink.c +0
-0index 9e1fb82..ea11cb4 100644
---
a/net/irda/irnetlink.c+++
b/net/irda/irnetlink.cnet/irda/irnetlink.c +0
-0@@ -101,8 +101,8 @@ static int irda_nl_get_mode(struct sk_buff *skb,struct
genl_info*info)Quoted 15 lines
net/irda/irnetlink.c +2
-2hdr =genlmsg_put (msg, info->snd_pid, info->snd_seq, &irda_nl_family,0 ,IRDA_NL_CMD_GET_MODE ); -if (IS_ERR (hdr)) { - ret =PTR_ERR (hdr); +if (hdr ==NULL ) { + ret = -ENOMEM ; goto err_out;
Quoted 7 lines
Quoted 1 line
}
Good catch, but the correct return value for insufficient
space in the skb is
-ENOSPC.
Thanks Julius, Patrick. I'll take this one and send it with
my next IrDA patch set.
Cheers,
Samuel.
Quoted 2 lines · Patrick McHardy
Good catch, but the correct return value for insufficient space in the skb is
-ENOSPC.
Hm, seems we have many inconsistent values returned in exactly this situation (in response to genlmsg_put), but none of them are -ENOSPC:
fs/dlm/netlink.c: -EINVALnet/netlink/genetlink.c: -1net/netlabel/netlabel_unlabeled.c: -ENOMEMnet/netlabel/netlabel_cipso_v4.c: -ENOMEMnet/netlabel/netlabel_mgmt.c: -ENOMEMnet/wireless/nl80211.c: -1drivers/acpi/event.c: -ENOMEMkernel/taskstats.c: -EINVAL
Seems like -ENOMEM is most common, don't know if that means it's correct, though...
I was also using -ENOMEM in my Netlink code, so better convert all my new uses to -ENOSPC?
Julius
Signature · 1 line
Google Switzerland GmbH
Quoted 16 lines · Julius Volz
Quoted 2 lines · Patrick McHardy
Good catch, but the correct return value for insufficient space in the skb is
-ENOSPC.Hm, seems we have many inconsistent values returned in exactly this situation (in response to
genlmsg_put), but none of them are-ENOSPC:
fs/dlm/netlink.c:-EINVALnet/netlink/genetlink.c: -1net/netlabel/netlabel_unlabeled.c:-ENOMEMnet/netlabel/netlabel_cipso_v4.c:-ENOMEMnet/netlabel/netlabel_mgmt.c:-ENOMEMnet/wireless/nl80211.c: -1drivers/acpi/event.c:-ENOMEMkernel/taskstats.c:-EINVAL
Quoted 5 lines
Seems like
-ENOMEMis most common, don't know if that means it's correct, though...I was also using
-ENOMEMin my Netlink code, so better convert all my new uses to-ENOSPC?
Yes, all those should be using ENOSPC as well. nl80211 returns inconsistent errors currently (-1/EMSGSIZE), but doesn't propagate them back to userspace. That should probably be fixed as well.
Actually I was wrong, its EMSGSIZE, not ENOSPC that should be returned, its more fitting and what other netlink users do as well.
Quoted 7 lines · Patrick McHardy
Yes, all those should be using ENOSPC as well. nl80211 returns inconsistent errors currently (-1/EMSGSIZE), but doesn't propagate them back to userspace. That should probably be fixed as well.
Actually I was wrong, its EMSGSIZE, not ENOSPC that should be returned, its more fitting and what other netlink users do as well.
Thanks, I will use that then!
Julius
Signature · 1 line
Google Switzerland GmbH
PATCH 1/1 IRDA: Fix genlmsg_put() return value check.
In reply to Julius VolzFix an incorrect return value check of genlmsg_put() in irda_nl_get_mode(). genlmsg_put() does not use ERR_PTR() to encode return values, it just returns NULL on error.
--- net/irda/irnetlink.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/irda/irnetlink.c +2 -2
@@ -101,8 +101,8 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) hdr =genlmsg_put (msg, info->snd_pid, info->snd_seq, &irda_nl_family,0 ,IRDA_NL_CMD_GET_MODE ); -if (IS_ERR (hdr)) { - ret =PTR_ERR (hdr); +if (hdr ==NULL ) { + ret = -EMSGSIZE ; goto err_out; }
Signature · 1 line
1.5.3.6
David Miller
maintainerFrom: Julius Volz <[email protected]>
Date: Tue, 24 Jun 2008 11:29:14 +0200
Quoted 5 lines
Fix an incorrect return value check of
genlmsg_put()inirda_nl_get_mode().genlmsg_put()does not useERR_PTR()to encode return values, it just returns NULL on error.Signed-off-by Julius Volz <[email protected]>
I'm assuming Samuel will grab this and send it to me in his next IRDA merge to me.
On Fri, 27 Jun 2008 20:01:33 -0700 (PDT), David Miller
Quoted 16 lines · <[email protected]> wrote:
From: Julius Volz <[email protected]>
Date: Tue, 24 Jun 2008 11:29:14 +0200
Quoted 1 line
Fix an incorrect return value check of
genlmsg_put()in
irda_nl_get_mode().Quoted 5 lines
genlmsg_put()does not useERR_PTR()to encode return values, it justreturns NULL on error.
Quoted 7 lines
Quoted 1 line
Signed-off-by Julius Volz <[email protected]>I'm assuming Samuel will grab this and send it to me in his
next IRDA merge to me.
That's right. This should happen this week.
Cheers,
Samuel.