All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Quadros <roger.quadros@nokia.com>
To: ext Michal Nazarewicz <mina86@mina86.com>
Cc: <gregkh@suse.de>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] usb: gadget: f_mass_storage: Prevent NULL pointer dereference
Date: Tue, 5 Apr 2011 20:47:13 +0300	[thread overview]
Message-ID: <4D9B55A1.1080002@nokia.com> (raw)
In-Reply-To: <op.vtg2kx0d3l0zgt@mnazarewicz-glaptop>

On 04/05/2011 06:56 PM, ext Michal Nazarewicz wrote:
> On Tue, 05 Apr 2011 17:36:40 +0200, Roger Quadros
> <roger.quadros@nokia.com> wrote:
>> Prevent a NULL pointer dereference in fsg_config_from_params() if
>> 'file' parameter is not specified.
> 
> Have you observed this behaviour?  I don't see how it could happen with
> module parameters and if it appears in some gadget it's a bug in the

It can happen if the gadget that uses f_mass_storage specifies
file_count=1 and doesn't specify a file name.

> gadget.  Not that I'm saying checking for null pointer is a bad idea.

OK. let's do that then.

> 
>> Signed-off-by: Roger Quadros <roger.quadros@nokia.com>
>> ---
>>  drivers/usb/gadget/f_mass_storage.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/f_mass_storage.c
>> b/drivers/usb/gadget/f_mass_storage.c
>> index 5d7de93..f6bd001 100644
>> --- a/drivers/usb/gadget/f_mass_storage.c
>> +++ b/drivers/usb/gadget/f_mass_storage.c
>> @@ -3177,7 +3177,7 @@ fsg_config_from_params(struct fsg_config *cfg,
>>          lun->removable = /* Removable by default */
>>              params->removable_count <= i || params->removable[i];
>>          lun->filename =
>> -            params->file_count > i && params->file[i][0]
>> +            params->file_count > i && params->file[i]
> 
> You're removing the check if an empty file name has been specified.  It
> should read:
> 
> +            params->file_count > i && params->file[i] &&
> params->file[i][0]

Right.

> 
> And since the line is getting pretty long, maybe convert it to a proper
> “if”.  I'm sure Greg will like that. ;)
> 
>>              ? params->file[i]
>>              : 0;
>>      }
> 
ok.

-- 
regards,
-roger

  reply	other threads:[~2011-04-05 17:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 15:36 [PATCH 0/5] fixes for f_mass_storage Roger Quadros
2011-04-05 15:36 ` [PATCH 1/5] usb: gadget: f_mass_storage: Fix Bulk-only RESET handling Roger Quadros
2011-04-05 16:09   ` Michal Nazarewicz
2011-04-05 15:36 ` [PATCH 2/5] usb: gadget: f_mass_storage: If 'ro'/'cdrom' specified, open file as read-only Roger Quadros
2011-04-05 16:04   ` Michal Nazarewicz
2011-04-05 15:36 ` [PATCH 3/5] usb: gadget: f_mass_storage: Prevent NULL pointer dereference Roger Quadros
2011-04-05 15:56   ` Michal Nazarewicz
2011-04-05 17:47     ` Roger Quadros [this message]
2011-04-05 15:36 ` [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory leak Roger Quadros
2011-04-05 15:59   ` Michal Nazarewicz
2011-04-05 17:47     ` Roger Quadros
2011-04-05 15:36 ` [PATCH 5/5] usb: gadget: f_mass_storage: remove unnecessary initialization Roger Quadros
2011-04-05 16:01   ` Michal Nazarewicz
2011-04-05 16:10 ` [PATCH 0/5] fixes for f_mass_storage Michal Nazarewicz

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=4D9B55A1.1080002@nokia.com \
    --to=roger.quadros@nokia.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.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.