Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1088211pxb; Wed, 6 Apr 2022 08:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLRvpXSLOfH8ASTsWaVKjB4xx5rx6DNFf5wlbGBQxi2XZc+qMEwcjXudbPduwcei7QwiPA X-Received: by 2002:a17:903:40c7:b0:156:8b56:5fa1 with SMTP id t7-20020a17090340c700b001568b565fa1mr9126181pld.108.1649258776342; Wed, 06 Apr 2022 08:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649258776; cv=none; d=google.com; s=arc-20160816; b=C5xotA6h33KUOtMMKCsQvRrgboGeamn7qbG4nrXHu3g1wfp8e3R8spdNQRNFjoeCEa ImK01p1CjScjJIANEf0pZDhVjiDWrwXt7/ftskzv1sbGoLkwgo0bkz5X+8OFq6EWSnkj qMX2KwHI+O+c4npccGyToA5PlzQldd+w6QzXJ6EbM+YyNcE0jV3JYIqvbohsA/AHsEhB NmXiFKD39Tkx5vv+bdLmHE23OrATtaZfzE7wfa/VJe3dLWqyki0iJWtc2vIFfs+Plk3A yKPGEmECLNZ+gX4c8sW8rTz8HpSii37cZ5tBJ/BWfX8EoKyBoDHaIRoV1TRKRMviL2WY midw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:subject:cc:to:from:message-id :dkim-signature; bh=aX2filfSFEj5vBMtD43q72C68TIjG2JpIiWef2rV3lg=; b=cxzXy2dhrgDJccezXFId6NR2grt8NRqLZpARxbueLFhfbt2ivdiolRygePGqHuf45d vjbt2NCe7JlXDf+fkO/qIZ/awckLTdJEXFDQlwUQ1U1x/2gNrUFmE2oKnfODEKzgQEBs qgPhgncp42/bBnLerzmgJ45WouHTzoBB9wuKBUWVy7Hn+B7FLisZewa/tOjPFSYWyTjE BYoY49qOtUphHz4meaIJFdAOD1Y2D01ELHdnWClRmYCEOh4LoZgCiOfWg/CMgfksEuLn 5lzeSJ5wbdyIaynQdRIVP69tvrcYJp9A5gJzzjCFUvNGOLvQDso5ouCpS/DzbaIArGy/ qk7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=E28zaP7T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b123-20020a633481000000b0038251581ab5si16698308pga.291.2022.04.06.08.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=E28zaP7T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71941277967; Wed, 6 Apr 2022 06:32:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232900AbiDFNeA (ORCPT + 99 others); Wed, 6 Apr 2022 09:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233411AbiDFNdH (ORCPT ); Wed, 6 Apr 2022 09:33:07 -0400 Received: from out203-205-221-221.mail.qq.com (out203-205-221-221.mail.qq.com [203.205.221.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0B90E001 for ; Tue, 5 Apr 2022 20:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649217375; bh=aX2filfSFEj5vBMtD43q72C68TIjG2JpIiWef2rV3lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E28zaP7TQEUvBNeHb6QJmO473EclWSsICcw+wc9A9lnFZj7DaGqIvYaS/Jk/eruX9 P5Rle4I3eieJzPb5bW/Fshfx5ZBcKQ+g0lC9r/onVGlrapQVL76wQCu0CdlzsPn+h9 LIB7Glyi4Y+j9tyZlpcDEKermAe/fCEXZ5lFjwn0= Received: from localhost.localdomain ([43.227.136.188]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id E0BA308F; Wed, 06 Apr 2022 11:56:11 +0800 X-QQ-mid: xmsmtpt1649217371t6o8amq8i Message-ID: X-QQ-XMAILINFO: MR/iVh5QLeiepNVBjjotu9W2eBdd7jHW6cnVnmELCYwwUMVgL2mQq4KY3VBBF9 cPKOuTXTDxEZsF4qixtfqd9rEqGIxhPQywikdo1p4zK6aW8JCRv+ghnaJEhSe/PDDBdyImyUo3g3 FF87RBCNPex5ZbFSb5xi0TK3l2qycu3ow3kjef/HYctRyL0yU7W5/fSK4etKefUvPihQIEGFlKFi 2p14ULeSHV9jaQpUeLkzVmr01trjuwIK5i6CsLncOQkzZHI16MOgDuH1l08Pau5znM8gyFdWWmg0 f670YqeoVG0UQBSLVq5YoEUOlUPj52EjiaAUtC9wsDHXLLDOpnoj7OptdXktgM6H2nue8Wc1uTF9 i4dB8vP6/2UReWMbeeCT2h1g1F6Id2mhNrFgmR8VqyV14fvOhtfxJw/wn94xk1m42WE2nhe0T/S+ trgqb6HmFX8xkk7Et2jiXzrsYPrkynH2NOHv0614OMJCRSMp7lfVPpNkkZJtTqIH55WWxzRVUp2w ozu+2XzgsfmuByeHJ0/bg8kVCGqSjyorX26uxCgXvB98NqLjnKXcJb0Suq9Lk+hdQXsECgHS38vs +qSwLoCMuYIZXBze1POIwHK2iVwfOatcK+0Cn2JxTfVhON3aEHkHvaYjx2nTojFTFrZC19w3Ym1t EFJEHNd00nqemjycOlcr6YIkBsNpHRO/eSY90vJpRJ6Qb9Q3PASWxWQLMIPrflhqoheYN9oi8XZ/ zgX/QZy/rVlg0bbnlth66DlfNmY4X6sguXB92Ie0aa4I0Q/itvK7t5IBMCFz47aGY7gYVaEBjejS KviUvRKsHj4HkZsSavxhwAS17BvEYnzqv9urAKrq5UROP/qtGBUrIuTF5VapbZ/yqQ4oo2WPw2C6 ZRqeDxBW/YSkS5zbNbREQuLup5b/Q1qF4e3pWaM9WoWDmC5hUZKwdS/4ACOWTpH9dO7vzwKxNX6Z Igawm7xV55OswmFA9if6y8RogZZdQ5F1ReE3czHxY= From: xkernel.wang@foxmail.com To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH v3 3/3] staging: rtl8712: add two validation check in r8712_init_drv_sw() Date: Wed, 6 Apr 2022 11:56:01 +0800 X-OQ-MSGID: <20220406035601.12934-1-xkernel.wang@foxmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 From: Xiaoke Wang _r8712_init_xmit_priv() or _r8712_init_recv_priv() returns -ENOMEM when some allocations inside it failed. However, the caller, i.e., r8712_init_drv_sw(), does not properly validate their return status, which may lead to potential wrong memory access in the future. Therefore, this patch adds two validation check for their return status and properly jump to the corresponding error hanlding code if failures happen. Signed-off-by: Xiaoke Wang --- ChangeLog: v1->v2 adjust the sequence of patches in this series. v2->v3 update the description. 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 1f7ccec..0dbf8c2 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) goto free_evt_priv; - _r8712_init_xmit_priv(&padapter->xmitpriv, padapter); - _r8712_init_recv_priv(&padapter->recvpriv, padapter); + ret = _r8712_init_xmit_priv(&padapter->xmitpriv, padapter); + if (ret) + goto free_mlme_priv; + ret = _r8712_init_recv_priv(&padapter->recvpriv, padapter); + if (ret) + goto free_xmit_priv; memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); timer_setup(&padapter->securitypriv.tkip_timer, --