diff mbox series

scsi: mpi3mr: Fix an error code when probing the driver

Message ID 20220409134926.331728-1-zheyuma97@gmail.com (mailing list archive)
State Rejected
Headers show
Series scsi: mpi3mr: Fix an error code when probing the driver | expand

Commit Message

Zheyu Ma April 9, 2022, 1:49 p.m. UTC
During the process of driver probing, probe function should return < 0
for failure, otherwise kernel will treat value >= 0 as success.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/scsi/mpi3mr/mpi3mr_os.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Sathya Prakash Veerichetty April 12, 2022, 5:58 p.m. UTC | #1
On Sat, Apr 9, 2022 at 7:49 AM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value >= 0 as success.
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>  drivers/scsi/mpi3mr/mpi3mr_os.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index f7cd70a15ea6..240bfdf9788b 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -4222,9 +4222,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>         struct Scsi_Host *shost = NULL;
>         int retval = 0, i;
>
> -       if (osintfc_mrioc_security_status(pdev)) {
> +       retval = osintfc_mrioc_security_status(pdev);
> +       if (retval) {
>                 warn_non_secure_ctlr = 1;
> -               return 1; /* For Invalid and Tampered device */
> +               return retval; /* For Invalid and Tampered device */
>         }
NAK. The driver has to return 1 when invalid/tampered controllers are
detected just to say the controller is held by the mpi3mr driver
without any actual operation.
>
>         shost = scsi_host_alloc(&mpi3mr_driver_template,
> --
> 2.25.1
>
Zheyu Ma April 13, 2022, 9:27 a.m. UTC | #2
On Wed, Apr 13, 2022 at 1:58 AM Sathya Prakash Veerichetty
<sathya.prakash@broadcom.com> wrote:
>
> On Sat, Apr 9, 2022 at 7:49 AM Zheyu Ma <zheyuma97@gmail.com> wrote:
> >
> > During the process of driver probing, probe function should return < 0
> > for failure, otherwise kernel will treat value >= 0 as success.
> >
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> > ---
> >  drivers/scsi/mpi3mr/mpi3mr_os.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> > index f7cd70a15ea6..240bfdf9788b 100644
> > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> > @@ -4222,9 +4222,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> >         struct Scsi_Host *shost = NULL;
> >         int retval = 0, i;
> >
> > -       if (osintfc_mrioc_security_status(pdev)) {
> > +       retval = osintfc_mrioc_security_status(pdev);
> > +       if (retval) {
> >                 warn_non_secure_ctlr = 1;
> > -               return 1; /* For Invalid and Tampered device */
> > +               return retval; /* For Invalid and Tampered device */
> >         }
> NAK. The driver has to return 1 when invalid/tampered controllers are
> detected just to say the controller is held by the mpi3mr driver
> without any actual operation.

Thanks for your explanation, I will drop this patch.

Zheyu Ma
diff mbox series

Patch

diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index f7cd70a15ea6..240bfdf9788b 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -4222,9 +4222,10 @@  mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct Scsi_Host *shost = NULL;
 	int retval = 0, i;
 
-	if (osintfc_mrioc_security_status(pdev)) {
+	retval = osintfc_mrioc_security_status(pdev);
+	if (retval) {
 		warn_non_secure_ctlr = 1;
-		return 1; /* For Invalid and Tampered device */
+		return retval; /* For Invalid and Tampered device */
 	}
 
 	shost = scsi_host_alloc(&mpi3mr_driver_template,