Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3486696pxb; Mon, 4 Apr 2022 18:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdg5yCf7UxP66fnFgjraqbew8bo26N5YuZhnmOlwcDGLsoI76xm2FoiQLu3vVFjTGOVV9i X-Received: by 2002:a17:90b:1811:b0:1c7:832a:3388 with SMTP id lw17-20020a17090b181100b001c7832a3388mr1232207pjb.40.1649122339584; Mon, 04 Apr 2022 18:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122339; cv=none; d=google.com; s=arc-20160816; b=f5FNm6Zl3dQxoAfHxzH15BbLUY0q2LotrxrJhuT7vVN46S2+KPBKZ2clEhKNqiCFkj ebmv21LyX1tsZoW12UqBKLMEulY2VzjexiMb2ImSmvRVoMXDmHnx125PrdfC6+Iy262B AkQwZPkRyOOlX3nW3V5XZbN2oiGEQDatWXsyOhqz3qwH/gdY99GfeqEzMK+zRUHx6LYq Q0F+6Vp8LgkQ5acV4x+a/MdHD3chLt6Nb1H87vuYMyZhks7TX3b1DHZuXL+jPSOm2gmu zIQYZitzRzy5qmUDPDDAa38OBeKe4y1G+TUTWNFgkE4RWN6ufmjbyQOEevG5B0rN9McI k9ow== 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=x/Qm8R+RDPcXj3lGHWhaC0tNVwOWAPDGMhnhcPb6y4M=; b=gqVYBkWQlw6mh20+lUfFJfeyePuSVuBTM92gCiFm1O1+M2SpJker/nr0+Uzd1MhdDO PIX4isNNifFUkwmosIe5FMofICCMvViVxvdUPVrNsKwsPJO7+xkTHMQ8jeZyAhwJUBCi 8FTgG7Ubt5WP8M2+G8uuQmaqr2l7y36UTw69eF9olPl/rrlBrWTut+vM1aUCq+tp9k2Q 4Uc+3qmFeoirp68UhPb018a7mR/VWFfpBpnnGoJsc1REsugqeVW/qRgrUP21jKFkyLCs xrBBVn9At5R7greZ0HEN89H7t4FPjl6/KgLcTEkMgh1dppr3G4gObruYifZDvtskh4XQ Jh2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hx6l2VVU; 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 s6-20020a17090a948600b001caa4bef711si770378pjo.62.2022.04.04.18.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:32:19 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hx6l2VVU; 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 0FBAF1D7D8B; Mon, 4 Apr 2022 17:22:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377416AbiDDObu (ORCPT + 99 others); Mon, 4 Apr 2022 10:31:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377434AbiDDObo (ORCPT ); Mon, 4 Apr 2022 10:31:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEB5522B3B for ; Mon, 4 Apr 2022 07:29:38 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 7EEA4B81722 for ; Mon, 4 Apr 2022 14:29:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9DEBC2BBE4; Mon, 4 Apr 2022 14:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649082576; bh=aT8e3BlBfNipB4O093d7n5Op1VJKa4RJFODCpYYoFsw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hx6l2VVUpYnQOFTg6KmsjgZgEOjYARG7zUVdOY+6HXouOH7JSXoeRR3ZCcPm4fI1A gVmDDfxhmRkKO8FzUeus9PzqkUQFSbMftgH1JrPxn9zGjBssGxkSIULTsHybgnfqxA kg0HAuuvy56dEjOdoGDw33MvkEFbz891ehoXLHlw= Date: Mon, 4 Apr 2022 16:29:33 +0200 From: Greg KH To: xkernel.wang@foxmail.com Cc: Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] staging: rtl8712: add two validation check in r8712_init_drv_sw() 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, Apr 01, 2022 at 01:07:45AM +0800, xkernel.wang@foxmail.com wrote: > From: Xiaoke Wang > > _r8712_init_xmit_priv() or _r8712_init_recv_priv() returns -ENOMEM > when some allocations inside it failed. > So it is better to check the return status of them. > > Signed-off-by: Xiaoke Wang > --- > drivers/staging/rtl8712/os_intfs.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c > index 9502f6a..163baaa 100644 > --- a/drivers/staging/rtl8712/os_intfs.c > +++ b/drivers/staging/rtl8712/os_intfs.c > @@ -308,8 +308,12 @@ int r8712_init_drv_sw(struct _adapter *padapter) > ret = r8712_init_mlme_priv(padapter); > if (ret) > return ret; > - _r8712_init_xmit_priv(&padapter->xmitpriv, padapter); > - _r8712_init_recv_priv(&padapter->recvpriv, padapter); > + ret = _r8712_init_xmit_priv(&padapter->xmitpriv, padapter); > + if (ret) > + return ret; > + ret = _r8712_init_recv_priv(&padapter->recvpriv, padapter); > + if (ret) > + return ret; You just leaked memory :( please please please test these types of "fix up error handling" changes, as there are lots and lots of ways to get these wrong. If you can not test them, provide some sort of proof that the change is correct please. thanks, greg k-h