All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jitendra Bhivare <jitendra.bhivare@avagotech.com>
To: khoroshilov@ispras.ru
Cc: Jayamohan Kallickal <jayamohan.kallickal@avagotech.com>,
	Ketan Mukadam <ketan.mukadam@avagotech.com>,
	John Soni Jose <sony.john@avagotech.com>,
	"James E.J. Bottomley" <JBottomley@odin.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] be2iscsi: add checks for dma mapping errors
Date: Wed, 20 Jan 2016 11:50:06 +0530	[thread overview]
Message-ID: <e8b4bbae04fa08ad9d4aabc85557ac85@mail.gmail.com> (raw)

> -----Original Message-----
> From: Alexey Khoroshilov [mailto:khoroshilov@ispras.ru]
> Sent: Saturday, January 16, 2016 3:16 AM
> To: Jayamohan Kallickal; Ketan Mukadam; John Soni Jose
> Cc: Alexey Khoroshilov; James E.J. Bottomley; Martin K. Petersen;
> linux- scsi@vger.kernel.org; linux-kernel@vger.kernel.org; ldv-
> project@linuxtesting.org
> Subject: [PATCH] be2iscsi: add checks for dma mapping errors
>
> hwi_write_buffer() does not check if mapping dma memory succeed.
> The patch adds the check and failure handling.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
> b/drivers/scsi/be2iscsi/be_main.c index fe0c5143f8e6..1da9e31ea958
> 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -2504,7 +2504,7 @@ hwi_write_sgl(struct iscsi_wrb *pwrb, struct
> scatterlist *sg,
>   * @pwrb: ptr to the WRB entry
>   * @task: iscsi task which is to be executed
>   **/
> -static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct
> iscsi_task
> *task)
> +static int hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task
> +*task)
>  {
>  	struct iscsi_sge *psgl;
>  	struct beiscsi_io_task *io_task = task->dd_data; @@ -2536,6
+2536,9
> @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct
> iscsi_task
> *task)
>  							     task->data,
>
> task->data_count,
>
> PCI_DMA_TODEVICE);
> +			if (pci_dma_mapping_error(phba->pcidev,
> +						  io_task->mtask_addr))
> +				return -ENOMEM;
>  			io_task->mtask_data_count = task->data_count;
>  		} else
>  			io_task->mtask_addr = 0;
> @@ -2580,6 +2583,7 @@ static void hwi_write_buffer(struct iscsi_wrb
> *pwrb, struct iscsi_task *task)
>  		AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106);
>  	}
>  	AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
> +	return 0;
>  }
>
>  /**
> @@ -5025,6 +5029,7 @@ static int beiscsi_mtask(struct iscsi_task *task)
>  	unsigned int doorbell = 0;
>  	unsigned int cid;
>  	unsigned int pwrb_typeoffset = 0;
> +	int ret = 0;
>
>  	cid = beiscsi_conn->beiscsi_conn_cid;
>  	pwrb = io_task->pwrb_handle->pwrb;
> @@ -5073,7 +5078,7 @@ static int beiscsi_mtask(struct iscsi_task *task)
>  	case ISCSI_OP_LOGIN:
>  		AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 1);
>  		ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
> -		hwi_write_buffer(pwrb, task);
> +		ret = hwi_write_buffer(pwrb, task);
>  		break;
>  	case ISCSI_OP_NOOP_OUT:
>  		if (task->hdr->ttt != ISCSI_RESERVED_TAG) { @@ -5093,19
> +5098,19 @@ static int beiscsi_mtask(struct iscsi_task *task)
>  				AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
>  					      dmsg, pwrb, 0);
>  		}
> -		hwi_write_buffer(pwrb, task);
> +		ret = hwi_write_buffer(pwrb, task);
>  		break;
>  	case ISCSI_OP_TEXT:
>  		ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
> -		hwi_write_buffer(pwrb, task);
> +		ret = hwi_write_buffer(pwrb, task);
>  		break;
>  	case ISCSI_OP_SCSI_TMFUNC:
>  		ADAPTER_SET_WRB_TYPE(pwrb, INI_TMF_CMD, pwrb_typeoffset);
> -		hwi_write_buffer(pwrb, task);
> +		ret = hwi_write_buffer(pwrb, task);
>  		break;
>  	case ISCSI_OP_LOGOUT:
>  		ADAPTER_SET_WRB_TYPE(pwrb, HWH_TYPE_LOGOUT,
pwrb_typeoffset);
> -		hwi_write_buffer(pwrb, task);
> +		ret = hwi_write_buffer(pwrb, task);
>  		break;
>
>  	default:
> @@ -5116,6 +5121,9 @@ static int beiscsi_mtask(struct iscsi_task *task)
>  		return -EINVAL;
>  	}
>
> +	if (ret)
> +		return ret;
> +
>  	/* Set the task type */
>  	io_task->wrb_type = (is_chip_be2_be3r(phba)) ?
>  		AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb) :
> --
> 1.9.1
>
Reviewed-by: Jitendra Bhivare <jitendra.bhivare@avagotech.com>

Thanks,

JB

             reply	other threads:[~2016-01-20  6:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20  6:20 Jitendra Bhivare [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-01-15 21:45 [PATCH] be2iscsi: add checks for dma mapping errors Alexey Khoroshilov
2016-01-20  0:59 ` Martin K. Petersen
2016-01-27  1:46 ` Martin K. Petersen

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=e8b4bbae04fa08ad9d4aabc85557ac85@mail.gmail.com \
    --to=jitendra.bhivare@avagotech.com \
    --cc=JBottomley@odin.com \
    --cc=jayamohan.kallickal@avagotech.com \
    --cc=ketan.mukadam@avagotech.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sony.john@avagotech.com \
    /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.