Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp806556imw; Fri, 15 Jul 2022 13:16:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCBa+PzXM+0JjJmy9wRfvM+zj9jnJcqOP21/18qkq3mrI3AWZbv1NHpMif6HtakB3xxBd8 X-Received: by 2002:a63:6ac3:0:b0:411:4aa9:9034 with SMTP id f186-20020a636ac3000000b004114aa99034mr13901892pgc.94.1657916162139; Fri, 15 Jul 2022 13:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657916162; cv=none; d=google.com; s=arc-20160816; b=Zfy90lbY3auEPAmyZloa4a0cvl/ct7htgodKRwH/wXAZd+f5SezLoO49d5BrfnoK3T RtNuQclBUbqKulP7P5u7f7LsDsLWLfGT2sfu+pHUwQ3rDKz/0noFg6YmlG+fTL0clk9R dIaqOkS+856Thgq/DiOEyLJXJMh0ULsboPCIfoJVOatoM3dR/z3ZrA65NMMEoYJCPzG9 aWw1IXccRHjE7nx6/WaeI55rH0Rnkz27K/mG7fC2GOjxvjVVSVg86TzmZqS089rw/anY zaGHs7RNvHxaanOCC7zvzbt+p2nlOO4ov2BF/pzwI5aja01a+dTPY2OzNfog6bocCU3U pd8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=38XcX2YUik9lt5DzWrww5tGR5TlEJ/QeJmkryNsc4M0=; b=ZVIdLsfAGPa2l4S09FXaND5ra/MoFeV5J5et9loEjoA3s3ijuUX5GZxBU05NN/yoCE ltT1cUtfNDByO0gM3kCiIqwtpYNZJD7spx7jWx7uE+otd7XSX2fsTyxS4YKBCRPschQv vmHzigy2RppInOc8f5vlm5gM9i3FxLNsPvB+92fMqQkEKmBB3FdNqSWPLZLoPpDL1e+Y 7YYLuPoIQddEGnjRUTUiFGWUE92hrJaVZl1P1+C7iOMvDOZObZwPwJs04LMrVcgJmsuI kzxc+rdF397ptwUSpwh14Dj9+fTjj/rABgvo3F7gDrdgTcjr22esY/JYnx1KRciGK/Gj MOXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a17090a8d0900b001f0734f3988si5973372pjo.164.2022.07.15.13.15.44; Fri, 15 Jul 2022 13:16:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbiGOUMD (ORCPT + 99 others); Fri, 15 Jul 2022 16:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229970AbiGOUL7 (ORCPT ); Fri, 15 Jul 2022 16:11:59 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8040367C89 for ; Fri, 15 Jul 2022 13:11:58 -0700 (PDT) Received: from martin by viti.kaiser.cx with local (Exim 4.89) (envelope-from ) id 1oCRfC-0006TK-7c; Fri, 15 Jul 2022 22:11:50 +0200 Date: Fri, 15 Jul 2022 22:11:50 +0200 From: Martin Kaiser To: Pavel Skripkin Cc: Greg Kroah-Hartman , Larry Finger , Phillip Potter , Michael Straube , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH] staging: r888eu: use dynamic allocation for efuse buffer Message-ID: <20220715201150.nnbdfc4tgj67zyic@viti.kaiser.cx> References: <20220713075804.140986-1-martin@kaiser.cx> <5445d915-0c6c-b84f-158e-160e7645cbbd@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5445d915-0c6c-b84f-158e-160e7645cbbd@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: Martin Kaiser X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 Pavel, Thus wrote Pavel Skripkin (paskripkin@gmail.com): > 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 yes, that makes sense. We could refuse to load the driver in this case. Larry and Greg already accepted the patch as is, I'll add error handling in a separate patch. Thanks, Martin