All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhouyang Jia <jiazhouyang09@gmail.com>
To: Finn Thain <fthain@telegraphics.com.au>
Cc: Juergen Gross <jgross@suse.com>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	xen-devel@lists.xenproject.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH] scsi: xen-scsifront: add error handling for xenbus_printf
Date: Thu, 14 Jun 2018 16:13:21 +0800	[thread overview]
Message-ID: <CABb2TxJCd9Q0KUeeqZ_CZ-HwmkAVoktDLxq0TrThM2rFe4jePQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.21.1806132002180.45@nippy.intranet>


[-- Attachment #1.1: Type: text/plain, Size: 2490 bytes --]

Hi,

Sorry for the mistakes, I'll fix this in v2.

Best,
Zhouyang

2018-06-13 18:09 GMT+08:00 Finn Thain <fthain@telegraphics.com.au>:

> On Tue, 12 Jun 2018, Zhouyang Jia wrote:
>
> > When xenbus_printf fails, the lack of error-handling code may
> > cause unexpected results.
> >
> > This patch adds error-handling code after calling xenbus_printf.
> >
> > Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> > ---
> >  drivers/scsi/xen-scsifront.c | 31 ++++++++++++++++++++++++-------
> >  1 file changed, 24 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
> > index 36f59a1..3d858ac 100644
> > --- a/drivers/scsi/xen-scsifront.c
> > +++ b/drivers/scsi/xen-scsifront.c
> > @@ -654,10 +654,17 @@ static int scsifront_dev_reset_handler(struct
> scsi_cmnd *sc)
> >  static int scsifront_sdev_configure(struct scsi_device *sdev)
> >  {
> >       struct vscsifrnt_info *info = shost_priv(sdev->host);
> > +     struct xenbus_device *dev = info->dev;
> > +     int err;
> >
> > -     if (info && current == info->curr)
> > -             xenbus_printf(XBT_NIL, info->dev->nodename,
> > +     if (info && current == info->curr) {
> > +             err = xenbus_printf(XBT_NIL, info->dev->nodename,
> >                             info->dev_state_path, "%d",
> XenbusStateConnected);
>
> The existing code checks whether 'info' is NULL before dereferencing it.
> But your patch checks for NULL after dereferencing.
>
> > +             if (err) {
> > +                     dev_err(&dev->dev, "writing dev_state_path\n");
> > +                     return err;
> > +             }
> > +     }
> >
> >       return 0;
> >  }
> > @@ -665,10 +672,15 @@ static int scsifront_sdev_configure(struct
> scsi_device *sdev)
> >  static void scsifront_sdev_destroy(struct scsi_device *sdev)
> >  {
> >       struct vscsifrnt_info *info = shost_priv(sdev->host);
> > +     struct xenbus_device *dev = info->dev;
> > +     int err;
> >
> > -     if (info && current == info->curr)
> > -             xenbus_printf(XBT_NIL, info->dev->nodename,
> > +     if (info && current == info->curr) {
> > +             err = xenbus_printf(XBT_NIL, info->dev->nodename,
> >                             info->dev_state_path, "%d",
> XenbusStateClosed);
>
> Same here.
>
> > +             if (err)
> > +                     dev_err(&dev->dev, "writing dev_state_path\n");
> > +     }
> >  }
> >
> >  static struct scsi_host_template scsifront_sht = {
>
> --
>

[-- Attachment #1.2: Type: text/html, Size: 3659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-06-14  8:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  3:42 [PATCH] scsi: xen-scsifront: add error handling for xenbus_printf Zhouyang Jia
2018-06-12  3:42 ` Zhouyang Jia
2018-06-13 10:09 ` Finn Thain
2018-06-14  8:13   ` Zhouyang Jia [this message]
2018-06-13 10:09 ` Finn Thain
2018-06-14 16:08 ` [PATCH v2] " Zhouyang Jia
2018-06-14 16:08 ` Zhouyang Jia
2018-06-14 16:08   ` Zhouyang Jia
2018-06-14 21:54   ` Boris Ostrovsky
2018-06-14 21:54     ` Boris Ostrovsky
2018-06-14 22:59 ` [PATCH v3] " Zhouyang Jia
2018-06-14 22:59   ` Zhouyang Jia
2018-06-14 23:50   ` kbuild test robot
2018-06-14 23:50   ` kbuild test robot
2018-06-15  2:32   ` kbuild test robot
2018-06-15  2:32   ` kbuild test robot
2018-06-15  5:44   ` kbuild test robot
2018-06-15  5:44   ` kbuild test robot
2018-06-14 22:59 ` Zhouyang Jia
2018-06-15  1:48 ` [PATCH v4] " Zhouyang Jia
2018-06-15  1:48   ` Zhouyang Jia
2018-06-15  6:04   ` kbuild test robot
2018-06-15  6:04   ` kbuild test robot
2018-06-15 11:59   ` kbuild test robot
2018-06-15 11:59   ` kbuild test robot
2018-06-15  1:48 ` Zhouyang Jia
2018-06-15 17:05 ` [PATCH v5] " Zhouyang Jia
2018-06-15 17:05 ` Zhouyang Jia
2018-06-15 17:05   ` Zhouyang Jia
2018-06-19 12:53   ` Juergen Gross
2018-06-19 12:53   ` Juergen Gross
2018-06-19 13:02   ` Juergen Gross
2018-06-19 13:02   ` Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
2018-06-12  3:42 [PATCH] " Zhouyang Jia

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=CABb2TxJCd9Q0KUeeqZ_CZ-HwmkAVoktDLxq0TrThM2rFe4jePQ@mail.gmail.com \
    --to=jiazhouyang09@gmail.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=fthain@telegraphics.com.au \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.