Re: 2.6.9-rc1: selinux/hooks.c: functions returning unassignedvariables

From: Stephen Smalley
Date: Tue Aug 24 2004 - 10:49:24 EST


On Tue, 2004-08-24 at 11:33, Adrian Bunk wrote:
> On Tue, Aug 24, 2004 at 08:19:28AM -0700, John Cherry wrote:
> >...
> > security/selinux/hooks.c:2825: warning: `ret' might be used uninitialized in this function
> > security/selinux/hooks.c:2886: warning: `ret' might be used uninitialized in this function
>
>
> This was
> [NET]: Add skb_header_pointer, and use it where possible.
>
>
> @Dave:
> In both functions ret is returned, but line that assigned a value to ret
> was removed.

===== security/selinux/hooks.c 1.54 vs edited =====
--- 1.54/security/selinux/hooks.c 2004-08-18 20:14:54 -04:00
+++ edited/security/selinux/hooks.c 2004-08-24 08:43:51 -04:00
@@ -2822,7 +2822,7 @@
/* Returns error only if unable to parse addresses */
static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad)
{
- int offset, ihlen, ret;
+ int offset, ihlen, ret = -EINVAL;
struct iphdr _iph, *ih;

offset = skb->nh.raw - skb->data;
@@ -2836,6 +2836,7 @@

ad->u.net.v4info.saddr = ih->saddr;
ad->u.net.v4info.daddr = ih->daddr;
+ ret = 0;

switch (ih->protocol) {
case IPPROTO_TCP: {
@@ -2883,7 +2884,7 @@
static int selinux_parse_skb_ipv6(struct sk_buff *skb, struct avc_audit_data *ad)
{
u8 nexthdr;
- int ret, offset;
+ int ret = -EINVAL, offset;
struct ipv6hdr _ipv6h, *ip6;

offset = skb->nh.raw - skb->data;
@@ -2893,6 +2894,7 @@

ipv6_addr_copy(&ad->u.net.v6info.saddr, &ip6->saddr);
ipv6_addr_copy(&ad->u.net.v6info.daddr, &ip6->daddr);
+ ret = 0;

nexthdr = ip6->nexthdr;
offset += sizeof(_ipv6h);

--
Stephen Smalley <sds@xxxxxxxxxxxxxx>
National Security Agency

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/