All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Kiran Divekar <dkiran@marvell.com>
Cc: linux-wireless@vger.kernel.org
Subject: signedness bug in lbs_auth_to_authtype()
Date: Wed, 28 Mar 2012 10:24:57 +0300	[thread overview]
Message-ID: <20120328072456.GC3200@mwanda> (raw)

There is a signedness bug in lbs_auth_to_authtype() and it messes
up the error handling.

drivers/net/wireless/libertas/cfg.c
   106  static u8 lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
   107  {
   108          int ret = -ENOTSUPP;
   109  

We return -ENOTSUPP but it's casted to u8 making it 244.

   351          auth->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE);
   352          auth->header.len = cpu_to_le16(sizeof(*auth)-sizeof(auth->header));
   353          auth->auth = cpu_to_le16(lbs_auth_to_authtype(auth_type));
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We don't check for errors here.

   354          return sizeof(*auth);
   355  }

  1061          /* convert auth_type */
  1062          ret = lbs_auth_to_authtype(sme->auth_type);
  1063          if (ret < 0)
                    ^^^^^^^
This doesn't work because 244 is larger than zero.

  1064                  goto done;

I would just change the u8 to an int, except that I felt that maybe
we should be checking for errors on the first time this function is
called.  I wasn't sure how to handle that error.

regards,
dan carpenter

                 reply	other threads:[~2012-03-28  7:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120328072456.GC3200@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dkiran@marvell.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.