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 0A188C433E0 for ; Wed, 10 Feb 2021 08:07:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C04C564E40 for ; Wed, 10 Feb 2021 08:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233616AbhBJIHs (ORCPT ); Wed, 10 Feb 2021 03:07:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:44764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233501AbhBJIHj (ORCPT ); Wed, 10 Feb 2021 03:07:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 70194601FF; Wed, 10 Feb 2021 08:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612944419; bh=o/TOPS3k0kpXwL2Hy6xpabDld9yXGPoEwFHlhrBz/bI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DE+CAPc4vpkx4cmyO2B7uX8dzdvGhplkcvuXkxl16dJmd2MfshXH2DWSPZxK4uh2S 9fSvsN/hbmhGHAucDpGvkjmJ17C65Co20T4x/e06Arf35vSzjTgd9DAJyBY9yGIrHg I41SFYwWCqMeqrmfv/mK/ELI/neyV0TFImilxRY4= Date: Wed, 10 Feb 2021 09:06:56 +0100 From: Greg KH To: Amey Narkhede Cc: dan.carpenter@oracle.com, 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210210080134.1978-1-ameynarkhede03@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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