From: Felipe Balbi <balbi@ti.com>
To: Philippe De Swert <philippe.deswert@jollamobile.com>
Cc: <linux-usb@vger.kernel.org>, <gregkh@linuxfoundation.org>,
<balbi@ti.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget/composite : Avoid crash with bad gadget drivers
Date: Mon, 12 Aug 2013 13:08:04 -0500 [thread overview]
Message-ID: <20130812180804.GE27954@radagast> (raw)
In-Reply-To: <1376072588-2881-1-git-send-email-philippe.deswert@jollamobile.com>
[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]
On Fri, Aug 09, 2013 at 09:23:08PM +0300, Philippe De Swert wrote:
> Some bad gadget drivers do not check the return status of usb_add_config.
fix the gadget driver
> Thus they get a not correctly initialized config and when this gadget gets
> deactivated the whole kernel crashes. Since on initialization failure cdev
> is set to NULL it can be used to detect this problem situation. It can be
> argued that the faulty gadget driver should be fixed, but imho it is better
> to avoid crashing the kernel and letting the gadget developer know he/she
> is making a mistake. And have the developer of said gadget driver then fix
> the problem of course.
>
> Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
> ---
> drivers/usb/gadget/composite.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 55f4df6..e019bb5 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -848,12 +848,18 @@ void usb_remove_config(struct usb_composite_dev *cdev,
> {
> unsigned long flags;
>
> + if (config->cdev == NULL) {
> + pr_warn("Calling usb_remove_config without a matching usb_add_config!\n");
> + goto end;
> + }
I would take a WARN() only, but let the crash happen and fix the gadget
driver.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-08-12 18:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 18:23 [PATCH] usb: gadget/composite : Avoid crash with bad gadget drivers Philippe De Swert
2013-08-12 18:08 ` Felipe Balbi [this message]
2013-08-14 22:40 ` Philippe De Swert
2013-08-27 18:55 ` Felipe Balbi
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=20130812180804.GE27954@radagast \
--to=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=philippe.deswert@jollamobile.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox