All of lore.kernel.org
 help / color / mirror / Atom feed
* re: mtip32xx: add a status field to struct mtip_cmd
@ 2017-04-21 14:06 Colin Ian King
  2017-04-21 14:14 ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Colin Ian King @ 2017-04-21 14:06 UTC (permalink / raw)
  To: Christoph Hellwig, Johannes Thumshirn, Jens Axboe
  Cc: linux-kernel@vger.kernel.org

Hi,

CoverityScan found an issue with the following part of the patch:

-       if (likely(!reserv))
-               blk_mq_complete_request(rq, -ENODEV);
-       else if (test_bit(MTIP_PF_IC_ACTIVE_BIT, &dd->port->flags)) {
+       if (likely(!reserv)) {
+               cmd->status = -ENODEV;
+               blk_mq_complete_request(rq, 0);
+       } else if (test_bit(MTIP_PF_IC_ACTIVE_BIT, &dd->port->flags)) {


The issue is:

static void mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv)
{
        struct driver_data *dd = (struct driver_data *)data;
        struct mtip_cmd *cmd;

        if (likely(!reserv)) {
                cmd->status = -ENODEV;

CID 1430258 (#1 of 1): Uninitialized pointer write (UNINIT)4.
uninit_use: Using uninitialized value cmd.

..basically a null ptr dereference on cmd.

Colin

^ permalink raw reply	[flat|nested] 6+ messages in thread
* kill req->errors V2
@ 2017-04-18 15:52 Christoph Hellwig
  2017-04-18 15:52   ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2017-04-18 15:52 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, James Smart, Konrad Rzeszutek Wilk,
	Roger Pau Monné, linux-scsi, linux-nvme, linux-block,
	dm-devel

Currently the request structure has an errors field that is used in
various different ways.  The oldest drivers use it as an error count,
blk-mq and the generic timeout code assume that it holds a Linux
errno for block completions, and various drivers use it for internal
status values, often overwriting them with Linux errnos later,
that is unless they are processing passthrough requests in which
case they'll leave their errors in it.

This series kills the ->errors field and replaced it with new fields
in the drivers (or an odd hack in a union in struct request for
two bitrotting old drivers).

Also available in the following git tree:

    git://git.infradead.org/users/hch/block.git request-errors

Gitweb:

    http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/request-errors


Changes since V1:
 - rebased on top the latest block for-next tree
 - fix error handling in nfsd blocklayout
 - dropped "scsi: fix fast-fail for non-passthrough requests"

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-21 19:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-21 14:06 mtip32xx: add a status field to struct mtip_cmd Colin Ian King
2017-04-21 14:14 ` Jens Axboe
2017-04-21 14:37   ` Christoph Hellwig
2017-04-21 14:47     ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2017-04-18 15:52 kill req->errors V2 Christoph Hellwig
2017-04-18 15:52 ` mtip32xx: add a status field to struct mtip_cmd Christoph Hellwig
2017-04-18 15:52   ` Christoph Hellwig

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.