From patchwork Thu Aug 1 23:27:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 264151 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 1A51C2C008C for ; Fri, 2 Aug 2013 09:29:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE3474A09D; Fri, 2 Aug 2013 01:29:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 zwLLzTFvjPut; Fri, 2 Aug 2013 01:29:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8DEE04A0B5; Fri, 2 Aug 2013 01:28:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 488A74A03C for ; Fri, 2 Aug 2013 01:28:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 FV8BiVq7unA9 for ; Fri, 2 Aug 2013 01:28:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=ERR(-1.5) (only DNSBL check requested) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by theia.denx.de (Postfix) with ESMTPS id 1286B4A03F for ; Fri, 2 Aug 2013 01:27:50 +0200 (CEST) Received: by mail-pa0-f45.google.com with SMTP id bg4so2680601pad.4 for ; Thu, 01 Aug 2013 16:27:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=nm5RueIbxK5VG8DMkotq6JVrnOaglmHm9Cm4htmqrAE=; b=F+/wO22KFOQxyaItTu6tkXO18SACW1+OZd4xTPA04YXBI/NufbO6eJDYdxDhDHzzoC WFRdbt3dWnijMmGnybJVcVm1w+ckcIlkurZ8of/pXPA7ewZummc66P6+vlUrl2fJnOTH I3oHoG16jeAk9+bI0UrGAGaeWmTStphgkzWBBuhUo5/SNAgFAwbeh0u05mOegJ8YGsDF uCCvXFIrGQr2hejKo6r4/U26nyJiQupPfngJqaUBMIEjuiLp78HHXvm0PIsRvdSFsRUO PL6F5ITajDwSql6GFkNQqVEREdqxcn2Jt35U2BqTbHztJIocND2I7taEzS5bE0JdmYV9 l6/Q== X-Received: by 10.68.190.133 with SMTP id gq5mr4498708pbc.167.1375399668989; Thu, 01 Aug 2013 16:27:48 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPSA id qp10sm3799715pab.13.2013.08.01.16.27.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Aug 2013 16:27:47 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.80) (envelope-from ) id 1V52HW-0006gw-UD; Thu, 01 Aug 2013 16:27:42 -0700 From: Troy Kisky To: marek.vasut@gmail.com Date: Thu, 1 Aug 2013 16:27:24 -0700 Message-Id: <1375399657-25642-8-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375399657-25642-1-git-send-email-troy.kisky@boundarydevices.com> References: <1375399657-25642-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQkevQGbsMMwV8cCYu+IXQqhLvgu2Fm7c5dp8zvVHp/BcRYPiXR1ec74GRZImIAWeg8N1nvD Cc: fabio.estevam@freescale.com, otavio@ossystems.com.br, leiwen@marvell.com, u-boot@lists.denx.de Subject: [U-Boot] [PATCH V3 07/20] usb: gadget: config: fix unaligned access issues X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 Signed-off-by: Troy Kisky --- drivers/usb/gadget/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f563afe..014a679 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -86,7 +87,8 @@ int usb_gadget_config_buf( /* config descriptor first */ if (length < USB_DT_CONFIG_SIZE || !desc) return -EINVAL; - *cp = *config; + /* config need not be aligned */ + memcpy(cp, config, sizeof(*cp)); /* then interface/endpoint/class/vendor/... */ len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf, @@ -100,7 +102,7 @@ int usb_gadget_config_buf( /* patch up the config descriptor */ cp->bLength = USB_DT_CONFIG_SIZE; cp->bDescriptorType = USB_DT_CONFIG; - cp->wTotalLength = cpu_to_le16(len); + put_unaligned_le16(len, &cp->wTotalLength); cp->bmAttributes |= USB_CONFIG_ATT_ONE; return len; }