From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24475C433DB for ; Wed, 10 Feb 2021 09:16:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE9E861481 for ; Wed, 10 Feb 2021 09:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbhBJJPs (ORCPT ); Wed, 10 Feb 2021 04:15:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:53972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbhBJJKG (ORCPT ); Wed, 10 Feb 2021 04:10:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B37B64E53; Wed, 10 Feb 2021 09:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612948153; bh=JeAKwEtzgqGCw6CFOaksMkSTwUMVf0rtgYMmRNER66c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Fb7bQ2h9/YqZFmNJG2/xrpJTRU/CgkGBUSpHS/Ytn2XgH2Vy9kExs5z1INUC2vopr slIBlWV25ylralQUIuS4RFQ9aqvfSrVDDnFOVhPHi4uAv+JtVIhIDtQDJt81jKrGaN dekSZ4C9l7KHaFIGNybn2FARbpQod8OGQwq8TXdM= Date: Wed, 10 Feb 2021 10:09:11 +0100 From: Greg KH To: Amey Narkhede Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] staging: gdm724x: Fix DMA from stack Message-ID: References: <20210210080134.1978-1-ameynarkhede03@gmail.com> <20210210085811.7dunnfly6cqw67m3@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210210085811.7dunnfly6cqw67m3@archlinux> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 02:28:11PM +0530, Amey Narkhede wrote: > On 21/02/10 09:06AM, Greg KH wrote: > > On Wed, Feb 10, 2021 at 01:31:34PM +0530, Amey Narkhede wrote: > > > Stack allocated buffers cannot be used for DMA > > > on all architectures so allocate hci_packet buffer > > > using kzalloc(). > > > > > > Signed-off-by: Amey Narkhede > > > --- > > > Changes in v2: > > > - Fixed build warning > > > - Fixed memory leak using kfree > > > > > > drivers/staging/gdm724x/gdm_usb.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c > > > index dc4da66c3..c4a9b90c5 100644 > > > --- a/drivers/staging/gdm724x/gdm_usb.c > > > +++ b/drivers/staging/gdm724x/gdm_usb.c > > > @@ -56,11 +56,15 @@ static int gdm_usb_recv(void *priv_dev, > > > > > > static int request_mac_address(struct lte_udev *udev) > > > { > > > - u8 buf[16] = {0,}; > > > - struct hci_packet *hci = (struct hci_packet *)buf; > > > + u8 *buf; > > > + struct hci_packet *hci; > > > struct usb_device *usbdev = udev->usbdev; > > > int actual; > > > int ret = -1; > > > + buf = kzalloc(16, GFP_KERNEL); > > > > checkpatch did not complain about this? > No. checkpatch shows no errors and warnings. Please add a blank line after variables and before logic. > > And why do you need 'buf' anymore now? Why not just allocate hci and > > pass that to the request instead? Saves you an extra cast and an extra > > pointer. > > > > thanks, > > > > greg k-h > Thanks. I'll send v3. I assume now we don't need kzalloc anymore as we initialize > the hci_packet so kmalloc(sizeof(struct hci_packet),..) will do. Why is it needed now? And why would that change? thanks, greg k-h