From patchwork Thu Jan 8 17:51:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nable X-Patchwork-Id: 426751 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5E0FE14027F for ; Fri, 9 Jan 2015 04:52:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C66CF4B601; Thu, 8 Jan 2015 18:52:38 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xR2atGJLvklS; Thu, 8 Jan 2015 18:52:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C13F64B5E9; Thu, 8 Jan 2015 18:52:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6DBA64B5E9 for ; Thu, 8 Jan 2015 18:52:33 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uPpK0bcTZJf1 for ; Thu, 8 Jan 2015 18:52:33 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by theia.denx.de (Postfix) with ESMTPS id 36A4F4B5E4 for ; Thu, 8 Jan 2015 18:52:30 +0100 (CET) Received: by mail-lb0-f178.google.com with SMTP id u14so4178678lbd.9 for ; Thu, 08 Jan 2015 09:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=X1tQz/bwslguUaS0LPOuXg3Jb1ytCx1kcZRrshmBiR0=; b=uIpldBS2X+5UOA2xiL5CE0RZJY8dj5Pjhoo8cuaZqsaWimBjG+e2gzChKdnpj8h3rX bLeRWIXoHXvCVGDwcP0LaCv0XHNgsO+4SqoaCx0+oD0u/xpP653uSYLF/FdpPGiE3y3q 9VgRXpWq8SjRnql66gvakAVhu0zCjfOG6LGfyBkbksMiR56Nxpindkgs1ojGGu/MJwQy kQSNHH78QMaMPsXsI3x7o9q9DQ9zdKsdKFH1eGIaYGBhfqxfpmsWwiVch0VgBYYa8qcO XZZxWpp7/oFJtnIC9J3sbrmAYCnQpRIPivNamC0SJ+TCp16u7JJ0iPTXOiWRBob2gRRi v22g== X-Received: by 10.112.164.102 with SMTP id yp6mr15656684lbb.15.1420739549914; Thu, 08 Jan 2015 09:52:29 -0800 (PST) Received: from localhost.localdomain ([93.175.16.64]) by mx.google.com with ESMTPSA id h7sm1281628lbl.41.2015.01.08.09.52.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jan 2015 09:52:29 -0800 (PST) From: Alex Sadovsky X-Google-Original-From: Alex Sadovsky To: u-boot@lists.denx.de Date: Thu, 8 Jan 2015 20:51:10 +0300 Message-Id: <1420739470-6988-1-git-send-email-Nable.MainInbox@googlemail.com> X-Mailer: git-send-email 2.1.4 Cc: Marek Vasut , =?UTF-8?q?=C5=81ukasz=20Da=C5=82ek?= Subject: [U-Boot] [PATCH RESEND] usb: gadget: pxa25x_udc: fix use-before-initialized bug X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Fix use-before-initialized bug in pxa25x_udc driver. Function usb_gadget_register_driver calls udc_disable, and udc_disable calls pullup_off that uses dev->mach->udc_command. But dev->mach is initialized in usb_gadget_register_driver after calling udc_disable. This patch fixes the order of initialization. Signed-off-by: Alex Sadovsky --- I'm resending the patch with fixed 'Signed-off-by:' and 'From:' fields. There are no changes in patch contents. drivers/usb/gadget/pxa25x_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 8945c5b..d4460b2 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c @@ -1950,11 +1950,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) dev->watchdog.period = 5000 * CONFIG_SYS_HZ / 1000000; /* 5 ms */ dev->watchdog.function = udc_watchdog; + dev->mach = &mach_info; + udc_disable(dev); udc_reinit(dev); - dev->mach = &mach_info; - dev->gadget.name = "pxa2xx_udc"; retval = driver->bind(&dev->gadget); if (retval) {