* [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture()
@ 2022-09-15 11:10 Dan Carpenter
2022-09-15 11:11 ` [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler() Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2022-09-15 11:10 UTC (permalink / raw)
To: Sathya Prakash Veerichetty, Sreekanth Reddy
Cc: Kashyap Desai, Sumit Saxena, James E.J. Bottomley,
Martin K. Petersen, Himanshu Madhani, mpi3mr-linuxdrv.pdl,
linux-scsi, kernel-janitors
There are three error paths which return success:
1) Propagate the error code from mpi3mr_post_transport_req() if it fails.
2) Return -EINVAL if "ioc_status != MPI3_IOCSTATUS_SUCCESS".
3) Return -EINVAL if "le16_to_cpu(mpi_reply.response_data_length) !=
sizeof(struct rep_manu_reply)"
Fixes: 2bd37e284914 ("scsi: mpi3mr: Add framework to issue MPT transport cmds")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/scsi/mpi3mr/mpi3mr_transport.c | 58 ++++++++++++++------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
index 2367d9fe3fb9..74313cf68ad3 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
@@ -145,6 +145,7 @@ static int mpi3mr_report_manufacture(struct mpi3mr_ioc *mrioc,
u16 request_sz = sizeof(struct mpi3_smp_passthrough_request);
u16 reply_sz = sizeof(struct mpi3_smp_passthrough_reply);
u16 ioc_status;
+ u8 *tmp;
if (mrioc->reset_in_progress) {
ioc_err(mrioc, "%s: host reset in progress!\n", __func__);
@@ -186,41 +187,46 @@ static int mpi3mr_report_manufacture(struct mpi3mr_ioc *mrioc,
"sending report manufacturer SMP request to sas_address(0x%016llx), port(%d)\n",
(unsigned long long)sas_address, port_id);
- if (mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
- &mpi_reply, reply_sz, MPI3MR_INTADMCMD_TIMEOUT, &ioc_status))
+ rc = mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
+ &mpi_reply, reply_sz,
+ MPI3MR_INTADMCMD_TIMEOUT, &ioc_status);
+ if (rc)
goto out;
dprint_transport_info(mrioc,
"report manufacturer SMP request completed with ioc_status(0x%04x)\n",
ioc_status);
- if (ioc_status == MPI3_IOCSTATUS_SUCCESS) {
- u8 *tmp;
+ if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
+ rc = -EINVAL;
+ goto out;
+ }
- dprint_transport_info(mrioc,
- "report manufacturer - reply data transfer size(%d)\n",
- le16_to_cpu(mpi_reply.response_data_length));
+ dprint_transport_info(mrioc,
+ "report manufacturer - reply data transfer size(%d)\n",
+ le16_to_cpu(mpi_reply.response_data_length));
- if (le16_to_cpu(mpi_reply.response_data_length) !=
- sizeof(struct rep_manu_reply))
- goto out;
+ if (le16_to_cpu(mpi_reply.response_data_length) !=
+ sizeof(struct rep_manu_reply)) {
+ rc = -EINVAL;
+ goto out;
+ }
- strscpy(edev->vendor_id, manufacture_reply->vendor_id,
- SAS_EXPANDER_VENDOR_ID_LEN);
- strscpy(edev->product_id, manufacture_reply->product_id,
- SAS_EXPANDER_PRODUCT_ID_LEN);
- strscpy(edev->product_rev, manufacture_reply->product_rev,
- SAS_EXPANDER_PRODUCT_REV_LEN);
- edev->level = manufacture_reply->sas_format & 1;
- if (edev->level) {
- strscpy(edev->component_vendor_id,
- manufacture_reply->component_vendor_id,
- SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
- tmp = (u8 *)&manufacture_reply->component_id;
- edev->component_id = tmp[0] << 8 | tmp[1];
- edev->component_revision_id =
- manufacture_reply->component_revision_id;
- }
+ strscpy(edev->vendor_id, manufacture_reply->vendor_id,
+ SAS_EXPANDER_VENDOR_ID_LEN);
+ strscpy(edev->product_id, manufacture_reply->product_id,
+ SAS_EXPANDER_PRODUCT_ID_LEN);
+ strscpy(edev->product_rev, manufacture_reply->product_rev,
+ SAS_EXPANDER_PRODUCT_REV_LEN);
+ edev->level = manufacture_reply->sas_format & 1;
+ if (edev->level) {
+ strscpy(edev->component_vendor_id,
+ manufacture_reply->component_vendor_id,
+ SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
+ tmp = (u8 *)&manufacture_reply->component_id;
+ edev->component_id = tmp[0] << 8 | tmp[1];
+ edev->component_revision_id =
+ manufacture_reply->component_revision_id;
}
out:
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler()
2022-09-15 11:10 [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Dan Carpenter
@ 2022-09-15 11:11 ` Dan Carpenter
2022-09-15 17:31 ` Sathya Prakash Veerichetty
2022-09-15 17:35 ` [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Sathya Prakash Veerichetty
2022-09-16 2:04 ` Martin K. Petersen
2 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-09-15 11:11 UTC (permalink / raw)
To: Sathya Prakash Veerichetty, Sreekanth Reddy
Cc: Kashyap Desai, Sumit Saxena, James E.J. Bottomley,
Martin K. Petersen, Himanshu Madhani, mpi3mr-linuxdrv.pdl,
linux-scsi, kernel-janitors
The error code from mpi3mr_post_transport_req() is supposed to be
passed to bsg_job_done(job, rc, reslen), but it isn't.
Fixes: 176d4aa69c6e ("scsi: mpi3mr: Support SAS transport class callbacks")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/scsi/mpi3mr/mpi3mr_transport.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
index 74313cf68ad3..3fc897336b5e 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
@@ -3245,8 +3245,10 @@ mpi3mr_transport_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
dprint_transport_info(mrioc, "sending SMP request\n");
- if (mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
- &mpi_reply, reply_sz, MPI3MR_INTADMCMD_TIMEOUT, &ioc_status))
+ rc = mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
+ &mpi_reply, reply_sz,
+ MPI3MR_INTADMCMD_TIMEOUT, &ioc_status);
+ if (rc)
goto unmap_in;
dprint_transport_info(mrioc,
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler()
2022-09-15 11:11 ` [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler() Dan Carpenter
@ 2022-09-15 17:31 ` Sathya Prakash Veerichetty
0 siblings, 0 replies; 5+ messages in thread
From: Sathya Prakash Veerichetty @ 2022-09-15 17:31 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sreekanth Reddy, Kashyap Desai, Sumit Saxena,
James E.J. Bottomley, Martin K. Petersen, Himanshu Madhani,
mpi3mr-drvr-developers, linux-scsi, kernel-janitors
ACK. Thanks for fixing it.
On Thu, Sep 15, 2022 at 5:11 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The error code from mpi3mr_post_transport_req() is supposed to be
> passed to bsg_job_done(job, rc, reslen), but it isn't.
>
> Fixes: 176d4aa69c6e ("scsi: mpi3mr: Support SAS transport class callbacks")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/scsi/mpi3mr/mpi3mr_transport.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
> index 74313cf68ad3..3fc897336b5e 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
> @@ -3245,8 +3245,10 @@ mpi3mr_transport_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
>
> dprint_transport_info(mrioc, "sending SMP request\n");
>
> - if (mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
> - &mpi_reply, reply_sz, MPI3MR_INTADMCMD_TIMEOUT, &ioc_status))
> + rc = mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
> + &mpi_reply, reply_sz,
> + MPI3MR_INTADMCMD_TIMEOUT, &ioc_status);
> + if (rc)
> goto unmap_in;
>
> dprint_transport_info(mrioc,
> --
> 2.35.1
>
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture()
2022-09-15 11:10 [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Dan Carpenter
2022-09-15 11:11 ` [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler() Dan Carpenter
@ 2022-09-15 17:35 ` Sathya Prakash Veerichetty
2022-09-16 2:04 ` Martin K. Petersen
2 siblings, 0 replies; 5+ messages in thread
From: Sathya Prakash Veerichetty @ 2022-09-15 17:35 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sreekanth Reddy, Kashyap Desai, Sumit Saxena,
James E.J. Bottomley, Martin K. Petersen, Himanshu Madhani,
mpi3mr-drvr-developers, linux-scsi, kernel-janitors
ACK.
On Thu, Sep 15, 2022 at 5:10 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> There are three error paths which return success:
> 1) Propagate the error code from mpi3mr_post_transport_req() if it fails.
> 2) Return -EINVAL if "ioc_status != MPI3_IOCSTATUS_SUCCESS".
> 3) Return -EINVAL if "le16_to_cpu(mpi_reply.response_data_length) !=
> sizeof(struct rep_manu_reply)"
>
> Fixes: 2bd37e284914 ("scsi: mpi3mr: Add framework to issue MPT transport cmds")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/scsi/mpi3mr/mpi3mr_transport.c | 58 ++++++++++++++------------
> 1 file changed, 32 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
> index 2367d9fe3fb9..74313cf68ad3 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
> @@ -145,6 +145,7 @@ static int mpi3mr_report_manufacture(struct mpi3mr_ioc *mrioc,
> u16 request_sz = sizeof(struct mpi3_smp_passthrough_request);
> u16 reply_sz = sizeof(struct mpi3_smp_passthrough_reply);
> u16 ioc_status;
> + u8 *tmp;
>
> if (mrioc->reset_in_progress) {
> ioc_err(mrioc, "%s: host reset in progress!\n", __func__);
> @@ -186,41 +187,46 @@ static int mpi3mr_report_manufacture(struct mpi3mr_ioc *mrioc,
> "sending report manufacturer SMP request to sas_address(0x%016llx), port(%d)\n",
> (unsigned long long)sas_address, port_id);
>
> - if (mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
> - &mpi_reply, reply_sz, MPI3MR_INTADMCMD_TIMEOUT, &ioc_status))
> + rc = mpi3mr_post_transport_req(mrioc, &mpi_request, request_sz,
> + &mpi_reply, reply_sz,
> + MPI3MR_INTADMCMD_TIMEOUT, &ioc_status);
> + if (rc)
> goto out;
>
> dprint_transport_info(mrioc,
> "report manufacturer SMP request completed with ioc_status(0x%04x)\n",
> ioc_status);
>
> - if (ioc_status == MPI3_IOCSTATUS_SUCCESS) {
> - u8 *tmp;
> + if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
> + rc = -EINVAL;
> + goto out;
> + }
>
> - dprint_transport_info(mrioc,
> - "report manufacturer - reply data transfer size(%d)\n",
> - le16_to_cpu(mpi_reply.response_data_length));
> + dprint_transport_info(mrioc,
> + "report manufacturer - reply data transfer size(%d)\n",
> + le16_to_cpu(mpi_reply.response_data_length));
>
> - if (le16_to_cpu(mpi_reply.response_data_length) !=
> - sizeof(struct rep_manu_reply))
> - goto out;
> + if (le16_to_cpu(mpi_reply.response_data_length) !=
> + sizeof(struct rep_manu_reply)) {
> + rc = -EINVAL;
> + goto out;
> + }
>
> - strscpy(edev->vendor_id, manufacture_reply->vendor_id,
> - SAS_EXPANDER_VENDOR_ID_LEN);
> - strscpy(edev->product_id, manufacture_reply->product_id,
> - SAS_EXPANDER_PRODUCT_ID_LEN);
> - strscpy(edev->product_rev, manufacture_reply->product_rev,
> - SAS_EXPANDER_PRODUCT_REV_LEN);
> - edev->level = manufacture_reply->sas_format & 1;
> - if (edev->level) {
> - strscpy(edev->component_vendor_id,
> - manufacture_reply->component_vendor_id,
> - SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
> - tmp = (u8 *)&manufacture_reply->component_id;
> - edev->component_id = tmp[0] << 8 | tmp[1];
> - edev->component_revision_id =
> - manufacture_reply->component_revision_id;
> - }
> + strscpy(edev->vendor_id, manufacture_reply->vendor_id,
> + SAS_EXPANDER_VENDOR_ID_LEN);
> + strscpy(edev->product_id, manufacture_reply->product_id,
> + SAS_EXPANDER_PRODUCT_ID_LEN);
> + strscpy(edev->product_rev, manufacture_reply->product_rev,
> + SAS_EXPANDER_PRODUCT_REV_LEN);
> + edev->level = manufacture_reply->sas_format & 1;
> + if (edev->level) {
> + strscpy(edev->component_vendor_id,
> + manufacture_reply->component_vendor_id,
> + SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
> + tmp = (u8 *)&manufacture_reply->component_id;
> + edev->component_id = tmp[0] << 8 | tmp[1];
> + edev->component_revision_id =
> + manufacture_reply->component_revision_id;
> }
>
> out:
> --
> 2.35.1
>
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture()
2022-09-15 11:10 [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Dan Carpenter
2022-09-15 11:11 ` [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler() Dan Carpenter
2022-09-15 17:35 ` [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Sathya Prakash Veerichetty
@ 2022-09-16 2:04 ` Martin K. Petersen
2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2022-09-16 2:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sathya Prakash Veerichetty, Sreekanth Reddy, Kashyap Desai,
Sumit Saxena, James E.J. Bottomley, Martin K. Petersen,
Himanshu Madhani, mpi3mr-linuxdrv.pdl, linux-scsi,
kernel-janitors
Dan,
> There are three error paths which return success:
> 1) Propagate the error code from mpi3mr_post_transport_req() if it fails.
> 2) Return -EINVAL if "ioc_status != MPI3_IOCSTATUS_SUCCESS".
> 3) Return -EINVAL if "le16_to_cpu(mpi_reply.response_data_length) !=
> sizeof(struct rep_manu_reply)"
Applied patches 1 and 2 to 6.1/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-16 2:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15 11:10 [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Dan Carpenter
2022-09-15 11:11 ` [PATCH 2/2] scsi: mpi3mr: Fix error code in mpi3mr_transport_smp_handler() Dan Carpenter
2022-09-15 17:31 ` Sathya Prakash Veerichetty
2022-09-15 17:35 ` [PATCH 1/2] scsi: mpi3mr: fix error codes in mpi3mr_report_manufacture() Sathya Prakash Veerichetty
2022-09-16 2:04 ` Martin K. Petersen
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).