Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753231AbcDVGxn (ORCPT ); Fri, 22 Apr 2016 02:53:43 -0400 Received: from dehamd003.servertools24.de ([31.47.254.18]:49016 "EHLO dehamd003.servertools24.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbcDVGxl (ORCPT ); Fri, 22 Apr 2016 02:53:41 -0400 Subject: Re: [PATCH] usb: core: Do not use sizeof on pointer type To: Vaishali Thakkar References: <1461304310-4808-1-git-send-email-vaishali.thakkar@oracle.com> Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org From: Clemens Ladisch Message-ID: <5719CA6E.1070809@ladisch.de> Date: Fri, 22 Apr 2016 08:53:34 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1461304310-4808-1-git-send-email-vaishali.thakkar@oracle.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-PPP-Message-ID: <20160422065336.695060.13855@dehamd003.servertools24.de> X-PPP-Vhost: ladisch.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 633 Lines: 27 Vaishali Thakkar wrote: > When sizeof is applied to a pointer typed expression, it gives > the size of the pointer. And why would that be wrong in this case? > +++ b/drivers/usb/core/hcd.c > @@ -1386,7 +1386,7 @@ static int hcd_alloc_coherent(struct usb_bus *bus, > return -EFAULT; > } > > - vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), > + vaddr = hcd_buffer_alloc(bus, size + sizeof(*vaddr), > mem_flags, dma_handle); > if (!vaddr) > return -ENOMEM; > Please note the following comment: /* * Store the virtual address of the buffer at the end * of the allocated dma buffer. [...] Regards, Clemens