Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1671217ioo; Sun, 22 May 2022 23:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+oeYia9l8Bg3rmInVJypcRCRettDhqkeA6MRBgrPfc8KijLwOvBhTOyqzr+ePG5XoygIE X-Received: by 2002:a17:90a:df18:b0:1df:8665:a472 with SMTP id gp24-20020a17090adf1800b001df8665a472mr23170218pjb.65.1653288581103; Sun, 22 May 2022 23:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653288581; cv=none; d=google.com; s=arc-20160816; b=0ITbet4wKEmq/a0Fc4zQkaoXwT6avBHX9LTCVxsMrCKHtutKfWxtGi0g2qEDUDN1GN +S8klPRghPjcPFw2aVz83ZtUmf2XoMwi0HG9Aw+2WPLFtgEyHoKzZopEjk0cNMkCrpO9 Ov3r55oVkAyA1XSY6dR75wP88dCkdvpG7PqPuXBlGXH9QWiTMzDjNg5O+bv0uBgsWzod wbOxzlcbFTo1E+Alq2oL8NRRvhj/oAWT0O0YrSjiYq8wUbSXtcySskBxCDBtgtchJ182 0x+hNYja3Jh7uwQgrq9V5eoAuXongw47kMdcwsAZZHNgb6RrXd//e3dIonP4v3E3zBM9 sXvw== 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=RCTx6DKK5OOmVLWgK7rBDS3v0GtlrnNUWi3FWlaanhQ=; b=oPNrUhbuRCZeR90lEbu5d+YFofY3PSWqzEM460gTO0Shqinxu7PnXygaRNq3+J6PBz 6zGGYtCt/MNUU5cym0LevJl2gF4IXYrFrxzKgWc9Zcs1zsMBP/sA/kkBblHs7ckX12I3 4NUWhDdhvuFezopLvnf5F0YJD0u6RRrQ6S+FH6EalgzzDE24sDpOycPYy4ePdGM7f3fr MAk0SBHkZWGm96z0cfMEuCScYxEp5BhwiFkvjVPZ5T2iAJYElc5Jy4Y20ePzGso8NrYS coaTJAc9y7WsRXz441kEeWiSE8hdeLYbaMPGbf83JfvmmsimdGRb597UCIQaXtAyBlSk IJSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i2-20020a655b82000000b003c6086f7cb8si9593812pgr.431.2022.05.22.23.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:49:41 -0700 (PDT) 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; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5DADE3FBC8; Sun, 22 May 2022 23:18:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245358AbiEUPuc (ORCPT + 99 others); Sat, 21 May 2022 11:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiEUPu2 (ORCPT ); Sat, 21 May 2022 11:50:28 -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 649FC674FB for ; Sat, 21 May 2022 08:50:27 -0700 (PDT) Received: from martin by viti.kaiser.cx with local (Exim 4.89) (envelope-from ) id 1nsRMv-0007kO-Vo; Sat, 21 May 2022 17:50:17 +0200 Date: Sat, 21 May 2022 17:50:17 +0200 From: Martin Kaiser To: Jiasheng Jiang Cc: dan.carpenter@oracle.com, Larry.Finger@lwfinger.net, phil@philpotter.co.uk, gregkh@linuxfoundation.org, straube.linux@gmail.com, fmdefrancesco@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] staging: r8188eu: add check for kzalloc Message-ID: <20220521155017.7jjz7prdnspm2276@viti.kaiser.cx> References: <20220518075957.514603-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220518075957.514603-1-jiasheng@iscas.ac.cn> User-Agent: NeoMutt/20170113 (1.7.2) Sender: Martin Kaiser X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Thus wrote Jiasheng Jiang (jiasheng@iscas.ac.cn): > As kzalloc() may return null pointer, it should be better to > check the return value and return error if fails in order > to avoid dereference of null pointer. > Moreover, the return value of rtw_alloc_hwxmits() should also > be dealt with. > Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver") > Signed-off-by: Jiasheng Jiang > --- > Changelog > v1 -> v2: > *Change 1. Make rtw_alloc_hwxmits() return -ENOMEM on failure > and zero on success. > v2 -> v3 > *Change 1. Add "res = _FAIL". > --- > drivers/staging/r8188eu/core/rtw_xmit.c | 13 +++++++++++-- > drivers/staging/r8188eu/include/rtw_xmit.h | 2 +- > 2 files changed, 12 insertions(+), 3 deletions(-) > diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c > index c2a550e7250e..2ee92bbe66a0 100644 > --- a/drivers/staging/r8188eu/core/rtw_xmit.c > +++ b/drivers/staging/r8188eu/core/rtw_xmit.c > @@ -178,7 +178,12 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) > pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; > - rtw_alloc_hwxmits(padapter); > + res = rtw_alloc_hwxmits(padapter); This commit introduces a regression. res is now 0 if the allocation succeeds. > + if (res) { > + res = _FAIL; > + goto exit; > + } > + > rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); > for (i = 0; i < 4; i++) > @@ -1474,7 +1479,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) res is still 0 here - but the caller of _rtw_init_xmit_priv compares this return value with _SUCCESS (1) or _FAIL (0) and interprets it as _FAIL. [ 3893.464932] r8188eu: module is from the staging directory, the quality is unknown, you have been warned. [ 3893.543204] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0) [ 3893.713123] EEPROM ID = 0x8129 [ 3893.719205] r8188eu 1-1.5:1.0: _rtw_init_xmit_priv failed [ 3893.823102] usb 1-1.5: reset full-speed USB device number 4 using ci_hdrc [ 3893.986936] usbcore: registered new interface driver r8188eu > return res; > }