netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Cc: netdev@vger.kernel.org
Subject: mlx4: smatch stuff: saving error codes in u8
Date: Thu, 15 Dec 2011 11:48:13 +0300	[thread overview]
Message-ID: <20111215084812.GA20924@elgon.mountain> (raw)

Hi Yevgeny,

Smatch complains about some recent changes to the mlx4 driver:
drivers/net/ethernet/mellanox/mlx4/cmd.c +364 mlx4_slave_cmd(27)
	warn: assigning -22 to unsigned variable 'vhcr->status'


   361                                          mlx4_err(dev, "response expected while"
   362                                                   "output mailbox is NULL for "
   363                                                   "command 0x%x\n", op);
   364                                          vhcr->status = -EINVAL;
                                                ^^^^^^^^^^^^^^^^^^^^^^^
This is supposed to store some hardware specific error codes.  -EINVAL
should be CMD_STAT_BAD_PARAM.  Saving negative numbers to unsigned char
doesn't work.

   365                                  }
   366                          }
   367                          ret = vhcr->status;
                                ^^^^^^^^^^^^^^^^^^^
We should be using the mlx4_status_to_errno() function here to translate
the hardware error codes to linux error codes.

Also "ret" here gets passed to the the callers who again save it to
vhcr_cmd->status = __mlx4_cmd() in mlx4_master_process_vhcr().  The
__mlx4_cmd() function only returns linux error codes, not hardware error
codes.

Also the mlx4_master_process_vhcr() function sets vhcr_cmd->status to
linux error codes (which is a mistake) but it doesn't set "ret" on all
paths so it sometimes returns success even though an error occured
(which is a second separate mistake).

regards,
dan carpenter

             reply	other threads:[~2011-12-15  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15  8:48 Dan Carpenter [this message]
2011-12-15  9:05 ` mlx4: smatch stuff: saving error codes in u8 Yevgeny Petrilin

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=20111215084812.GA20924@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=yevgenyp@mellanox.co.il \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).