Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp550679imw; Wed, 13 Jul 2022 03:43:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3bRPE8lp1GNbdTjiHu8jBQVmo1NLpgcKCImQPtNUPCZKjLAEiZHAXH92MYY/RT+FBQ3Mj X-Received: by 2002:a17:907:8a0e:b0:72b:9ca3:507 with SMTP id sc14-20020a1709078a0e00b0072b9ca30507mr2342031ejc.477.1657709001554; Wed, 13 Jul 2022 03:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657709001; cv=none; d=google.com; s=arc-20160816; b=bJ0uK/j/TYWvKtjozgqE2IONe0lj8DO8wlCBZYuQ9UYeKykqjXA3Zpi7UJx2eD9yPU sQ/WmL5P+bWy3arVfVg26+22G1+0Nsj6eb81rlXV44VxgqXll7BEnl09YHk9+2xeLIWv MWhjcNZKTN1SlVRJ9aw/ibexnAg+/el+sCxtyPi8N6Xf5nrjG36QWAZ++hgGzAB2irb5 t2WMvK00mHT4yU+B7hTI+U2rForh4q3cGNB2dsc8JtMxJFf69VFBcd5TIsHnYtQdo/PX yHw9L78cKnJ3Nqi4FlWxNed+L3SKKgPIrN7Hxn3EM6Q7VbsY4DHqmyDEEheybKbVkome ckxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=PQ7TlErz9smov0rfx19Na+1VuDOymVWccAObGubD7hE=; b=C+y8JuZGtE1F2ZASWaFVzni6y6UmJVSTCFWmu/8pL2PzywrmdNsQjHeg0CmqOpIvUA GW/iN3uUW+fD6+wPb14rfQWp4wdmpsRvb07FjEtHLv9ytqLqGMxeUfDSn3OnW9Jb0NV0 D2Ot0dtjrVqQxb7XV2vKTg/89h4ckpF/V+TQJ9i/NzqdwgbmkbyDjlPk57bKnblR7yR2 LvS6LmUrQsKu7eBZ5UNc8Tk/H+rKSuy6dX1qCT+I+R+UyIjLtb17LnLYULR8lJGwC8ZX 2QgQURQGeZ0G3UBVd3lui6yjw4MhW+O6yiAElVi/cxddfYj7FnbzMAmwsHUUsLkTwBAz XAfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j3Im0x2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a50cc4d000000b0043555742fb6si15229442edi.224.2022.07.13.03.42.52; Wed, 13 Jul 2022 03:43:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j3Im0x2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235805AbiGMKYs (ORCPT + 99 others); Wed, 13 Jul 2022 06:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234823AbiGMKYq (ORCPT ); Wed, 13 Jul 2022 06:24:46 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE1FDA78D for ; Wed, 13 Jul 2022 03:24:45 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id a9so18299733lfk.11 for ; Wed, 13 Jul 2022 03:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=PQ7TlErz9smov0rfx19Na+1VuDOymVWccAObGubD7hE=; b=j3Im0x2bE4D19GrrzFvEHiywctG624H/V6PfGPXeeKLO89ES02QmxTzGtZiHoSfIIt WQo8N59T2vYLPAiWh1ERS+CrQ9vxZBCNvCvU+KvuTIlx1M/nz1kBTeif1g8+mTRj4P+j ZfZVvzS5GEqgZ26cUr8/o34YBYoTItxb6hJze7yK33Z4zmygVaSrOj9nE+/ZmUn509G2 B+XGIYZWMD7Pp9QwwIrjFvEJsH09twOKr/GGqBORBJfmMhXv+bpSVlh8BKatiMg4LjPM Q+R3zzd0vuxbJgKsJ08pDTK4ivem9OatHJqy8v3a/Ovaj1kwIkPWE/UV+QuKb9pZ34w0 4tew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=PQ7TlErz9smov0rfx19Na+1VuDOymVWccAObGubD7hE=; b=HnTZ0+AbNdPykTvH5iCVOiCADfgU+DkRPoZmIYsS8yYdcXS5jVL8CTk/xBpMeF/uA6 e3uAO94se7BIdC5xWW/HwQrRYV0pnREyhWEwBmANdkZOFmY4WqHSH3X72+WyfP5y0+/I gQCvv8kYPNe/VupbK9fra+9+ZVh6rxolOrc6mkvX8RUwTtHbTXirdqwTEqjVEOL9QdnE HsaxUX7iUAmcJyIXFEH9ZqWC6dED32k9WGP5bXcHtpCVyIWOQRFcttL3DCBYK4EM5OSY 4JAH8qgxgvXGJviTGTFb7IuJ4755SpXm9lknl9fGi6K4nwHAR3HP3S0kzs6lXSbtC2bO Gu1g== X-Gm-Message-State: AJIora80GFkOx8u7xbpAEcQsYzb6XEcvVPKCM6K1McmhOQqK0KsdmRWD UUVSlNN0enaP6zuAHBrOoi8= X-Received: by 2002:a05:6512:2254:b0:489:d168:20cf with SMTP id i20-20020a056512225400b00489d16820cfmr1537677lfu.97.1657707883409; Wed, 13 Jul 2022 03:24:43 -0700 (PDT) Received: from [192.168.1.11] ([46.235.67.63]) by smtp.gmail.com with ESMTPSA id a28-20020a2eb17c000000b0025d3c2e6b8dsm2943803ljm.105.2022.07.13.03.24.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 03:24:42 -0700 (PDT) Message-ID: <5445d915-0c6c-b84f-158e-160e7645cbbd@gmail.com> Date: Wed, 13 Jul 2022 13:24:41 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] staging: r888eu: use dynamic allocation for efuse buffer Content-Language: en-US To: Martin Kaiser , Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Dan Carpenter References: <20220713075804.140986-1-martin@kaiser.cx> From: Pavel Skripkin In-Reply-To: <20220713075804.140986-1-martin@kaiser.cx> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Martin, Martin Kaiser says: > Use kmalloc to allocate the efuse buffer in ReadAdapterInfo8188EU and > free it on exit. This is better than using a 512 byte array on the stack. > > It's ok to drop the __aligned(4) qualifier. kmalloc aligns to > ARCH_KMALLOC_MINALIGN, this is at least 8 bytes. > > Suggested-by: Dan Carpenter > Suggested-by: Larry Finger > Signed-off-by: Martin Kaiser > --- > drivers/staging/r8188eu/hal/usb_halinit.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c > index 8902dda7b8d8..421fe7c40390 100644 > --- a/drivers/staging/r8188eu/hal/usb_halinit.c > +++ b/drivers/staging/r8188eu/hal/usb_halinit.c > @@ -926,7 +926,7 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter) > { > struct eeprom_priv *eeprom = &Adapter->eeprompriv; > struct led_priv *ledpriv = &Adapter->ledpriv; > - u8 efuse_buf[EFUSE_MAP_LEN_88E] __aligned(4); > + u8 *efuse_buf; > u8 eeValue; > int res; > > @@ -937,7 +937,10 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter) > > eeprom->bautoload_fail_flag = !(eeValue & EEPROM_EN); > > - memset(efuse_buf, 0xFF, sizeof(efuse_buf)); > + efuse_buf = kmalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); > + if (!efuse_buf) > + return; I think, it worth returning an error to caller. Functions right after the allocation do initialization, so leaving fields as-is seems to be dangerous Thanks, --Pavel Skripkin