From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH] usbnet: smsc95xx: simplify tx_fixup code Date: Fri, 05 Oct 2018 14:24:12 -0700 (PDT) Message-ID: <20181005.142412.601607260441380535.davem@davemloft.net> References: <59988ed22559410881addfecf58335eb@AcuMS.aculab.com> <20181002165602.21033-1-ben.dooks@codethink.co.uk> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, David.Laight@ACULAB.COM, oneukum@suse.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel@lists.codethink.co.uk To: ben.dooks@codethink.co.uk Return-path: In-Reply-To: <20181002165602.21033-1-ben.dooks@codethink.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org From: Ben Dooks Date: Tue, 2 Oct 2018 17:56:02 +0100 > - memcpy(skb->data, &tx_cmd_a, 4); > + ptr = skb_push(skb, 8); > + tx_cmd_a = cpu_to_le32(tx_cmd_a); > + tx_cmd_b = cpu_to_le32(tx_cmd_b); > + memcpy(ptr, &tx_cmd_a, 4); > + memcpy(ptr+4, &tx_cmd_b, 4); Even a memcpy() through a void pointer does not guarantee that gcc will not emit word sized loads and stores. You must use the get_unaligned()/put_unaligned() facilities to do this properly. I also agree that making a proper type and structure instead of using a void pointer would be better.