Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4425548pxb; Mon, 21 Feb 2022 21:13:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA4SPctM7hcUn9TDyuyTfr3tgITg6oejlaIlqXLWLu6CTt2T2D2ffvsdPKDazWdzXJ+Lmr X-Received: by 2002:a63:1d44:0:b0:373:5612:629b with SMTP id d4-20020a631d44000000b003735612629bmr18872183pgm.352.1645506810276; Mon, 21 Feb 2022 21:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506810; cv=none; d=google.com; s=arc-20160816; b=pTYv8IR0oR58ccBLipg9RfvqUegp7CYSF31NFBCFNAIsMBXiRzODkRylP90plpvy1T DkUeEEwHnnNYmYQwlYyTiN03K/qQ4uhS3IN3xW/GiYQcMlxq9fB71pmpKkroTKrdUiB9 GGvuZ0chdwyzyTunvwdPUa3visPjABL+eJIWAJ5SkuFQ6aDhF+EY3bv41Pz2JdA6RH6q 3pnwgcFTS/joFDa1oWxurZOtZZAExwZjWpkLrJ179Ta74U7Rq0qMT6tTO3jkiOKAhZJL +jYTWM2Oswq/FkyHSOqlWlNTX94P2kdXD1d9rBfiAyEEvk16v1kbn/MOPzA8wS5kDCBg BJAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9H6p6vByKMjX49/zrnif7Auc1/dmBztPNx5LJtHj0Ew=; b=DXht508CalWYBeIXD+8jKalkHRo5ejZe9T+y4gNb9CFmWxwUxmTY3SusUB6wTS3mDE ob0HgueqBLOeckf5D+OhpP90c1O7UsjNbo9LCAwKdY004goIEqsVIZvXsWUFYEpH41O9 BGhF3tKsq3GmAvAuAzYHhB/tzXwq8EkKrsOu8ebkFC0yeViPdLM87n8I2amb8inDAviq LinAdJ+Cj7vyW1lqmZes4URwG8KprjgYa8j7NOwHZECZcqTCfIO5IxDm4KJKZbcwY2qK oHiwNeXC05s3X2Cj8xbYWCsLblCU2t9ulhwn/wMcEBNARoshiWw4ugDqHF4dI/upLsn1 6UKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Hw+yRmA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m14si24273760pgu.313.2022.02.21.21.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:13:30 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Hw+yRmA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F8D0DE2C1; Mon, 21 Feb 2022 20:45:54 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237754AbiBURFv (ORCPT + 99 others); Mon, 21 Feb 2022 12:05:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236770AbiBURFt (ORCPT ); Mon, 21 Feb 2022 12:05:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6E7CCD2 for ; Mon, 21 Feb 2022 09:05:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4EE6E61359 for ; Mon, 21 Feb 2022 17:05:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 236EBC340E9; Mon, 21 Feb 2022 17:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645463124; bh=5MfT2oHc40ecxh8J5Ub5ggnpJn5KsjhhqhGoFvH2PBY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2Hw+yRmAqVoMat+juk54S2+mFp4mWhfVxu2KLCfHrJ8JUrst+w2uA7Ahf7716md/n RVbJbOkBdpZBeyLPuAL5Vwox7mWNlfschmfoWbDtNKqBMbh5rt7XR+wharlsAXRLGa okobl9AJXkSojAoVDgDxVigR3adCnawQZ3zgiz8s= Date: Mon, 21 Feb 2022 18:05:22 +0100 From: Greg KH To: xkernel.wang@foxmail.com Cc: jerome.pouiller@silabs.com, dan.carpenter@oracle.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] staging: wfx: check the return value of devm_kmalloc() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Fri, Feb 18, 2022 at 10:04:02PM +0800, xkernel.wang@foxmail.com wrote: > From: Xiaoke Wang > > devm_kmalloc() returns a pointer to allocated memory on success, NULL > on failure. While there is a memory allocation of devm_kmalloc() > without proper check. It is better to check the return value of it to > prevent wrong memory access. > And I use the err label which is introduced by the previous patch to > handle the error. > > Signed-off-by: Xiaoke Wang > --- > Changelog > v1->v2 update the description. > drivers/staging/wfx/main.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c > index 9ff69c5..85fcdc3 100644 > --- a/drivers/staging/wfx/main.c > +++ b/drivers/staging/wfx/main.c > @@ -294,6 +294,9 @@ struct wfx_dev *wfx_init_common(struct device *dev, > hw->wiphy->n_iface_combinations = ARRAY_SIZE(wfx_iface_combinations); > hw->wiphy->iface_combinations = wfx_iface_combinations; > hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmalloc(dev, sizeof(wfx_band_2ghz), GFP_KERNEL); > + if (!hw->wiphy->bands[NL80211_BAND_2GHZ]) > + goto err; > + > // FIXME: also copy wfx_rates and wfx_2ghz_chantable > memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, > sizeof(wfx_band_2ghz)); > -- This patch does not apply to my tree at all. Please rebase and resend. thanks, greg k-h