public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michal Nazarewicz" <mina86@mina86.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_mass_storage: common->curlun could be NULL
Date: Wed, 30 Nov 2011 13:08:29 +0000	[thread overview]
Message-ID: <op.v5rf4f163l0zgt@mpn-glaptop> (raw)
In-Reply-To: <1322600416.2182.48.camel@mars>

On Tue, 29 Nov 2011 22:00:16 +0100, Christoph Fritz <chf.fritz@googlemail.com> wrote:
> This patch adds a NULL check for common->curlun in case of an unknown_cmnd
> in do_scsi_command().

Did you actually encountered it? check_command() should set curlun, shouldn't it?

After calling check_command() curlun may be NULL only in two situations:
1. check_command() returned negative error code, or
2. we're dealing with INQUIRY or REQUEST_SENSE command.

In the first case, the line in question is not executed at all because of “if
(reply = 0)” check.

In the second case, we won't reach “unknown_cmnd” label because the two commands
have their own case labels and do not perform a goto.

So as far as I can see, common->curlun cannot be NULL in the place this patch
is fixing.

> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/usb/gadget/f_mass_storage.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index c39d588..0e42027 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2184,7 +2184,8 @@ unknown_cmnd:
>  		reply = check_command(common, common->cmnd_size,
>  				      DATA_DIR_UNKNOWN, 0xff, 0, unknown);
>  		if (reply = 0) {
> -			common->curlun->sense_data = SS_INVALID_COMMAND;
> +			if (common->curlun)
> +				common->curlun->sense_data = SS_INVALID_COMMAND;
>  			reply = -EINVAL;
>  		}
>  		break;

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

      reply	other threads:[~2011-11-30 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29 21:00 [PATCH] usb: gadget: f_mass_storage: common->curlun could be NULL Christoph Fritz
2011-11-30 13:08 ` Michal Nazarewicz [this message]

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=op.v5rf4f163l0zgt@mpn-glaptop \
    --to=mina86@mina86.com \
    --cc=kernel-janitors@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox