Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp471807pxb; Mon, 25 Apr 2022 14:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXbnvdSHO+wu45/wKLdYHBnDCNRezrl4zJRZkJzlByZz8RLCtOtIzZzXhmSzNkQ/DcfCPj X-Received: by 2002:a63:b58:0:b0:399:522b:d92f with SMTP id a24-20020a630b58000000b00399522bd92fmr16652409pgl.141.1650920980679; Mon, 25 Apr 2022 14:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650920980; cv=none; d=google.com; s=arc-20160816; b=tCF5Fzbs4rs0x07Mclq4wYfnBk9R6omFnXuGnT7iq6r0SU1dSlKirt9S1QvglNoTv3 9XpBDq95MjL2d1CpTF/R8Md4gFoA47HHc1FS/k1akBuWf75ORHVep2AyhJBKnVWO83Xx yNYxgkaonh0dtsFPI3ggv8xOvnHAcmhG3/gCbUzJwYHbZkU2J/PBhiKpzPpMxKg3Uecy m8H5hINUODJiisEbiRxUT1+xFXFFrVZ25nOqGrCj9SsMmR9efCwcLeK26Y792KZsFmmR Ndas7BpMZdnF4H6eeLr9Fa2Mf8nIbNOS7Uf7qNr6aIUEQH3XOYppqrTb2njkJw6isgtL vGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NXFAC2IHRVkyeVboZLBfX7Ba1biHdUse85NUhdHGxTI=; b=sQfoygIe1rOU33vA3H71MlQ3x6Vl9Yfwbzuaxr8Y+IXBy4gFSwDWAtlUCLoMjLOzhA SBnVWUiB5AftGGzaHr1Nnqe+cyTKmaWMKQgtcKo2D8URxgTG2JABRoy1BTYgZ/Q9PKei MiySKnQjQ7GzvcX8XpKuegFgjcZSXnKBbBUzxC+UupHdQ582lPh7mWy/0pWrE97wJciX kkDqP+HL/KlfxJj4hB5EKyayyP4O0de7G8YFSF2snlokQ0bB0srXNxsKRZoTtMBstwrR EGawEEZXdcrZVz4UYVSEgo7ZqHGmBpmk2BRdhakqQak24VmqVZSAuJijHBRm5TQFXoG9 1hFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WbCZmixV; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a170902ce0600b0015833d93f52si13969192plg.66.2022.04.25.14.09.22; Mon, 25 Apr 2022 14:09:40 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WbCZmixV; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244118AbiDYR6u (ORCPT + 99 others); Mon, 25 Apr 2022 13:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236920AbiDYR6t (ORCPT ); Mon, 25 Apr 2022 13:58:49 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEBDD1839A for ; Mon, 25 Apr 2022 10:55:43 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-e2fa360f6dso16896997fac.2 for ; Mon, 25 Apr 2022 10:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NXFAC2IHRVkyeVboZLBfX7Ba1biHdUse85NUhdHGxTI=; b=WbCZmixVJm2Bmbgib3awwgetaxMvcxocv1dRfoys8Ibh6yKiTzbSlMEfASsx8EJcGz MAMtlVp7hWjCvdVo5P58iEjT2QfTazUX+gup39QZ1eb/jrrObx14IoaKVf1PLPByYFhU VUtV2f4+kXPdiQTeipQJXJ4fgRM/XjRhRW6kiV+MhNiBsSMTyzvsVlDNRC3ocS6nDk98 ceJXxMQbAEO14zR68b4JKrMJXj4EoebLcC0BkHxGavO9f1xK/HFX1ubx3aRYNhpwtEwg ah9wTa8hvQIRQmuSxeu1lqXL9QDF8NoiQmzZt4xn/HN0bDgvTaEzRmT4NfDfC2xfVdzU QIaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NXFAC2IHRVkyeVboZLBfX7Ba1biHdUse85NUhdHGxTI=; b=WiXbwB1C64+sI+5qjSHNu+jz+C6eoNo3Mt8fFWYnn9Knlj9jr/zzD2YBV0yWJ+SP2P Uur7gsDvEC5Udy9lmTFlRH3V4bF6w1iRT1m1eE2/Wsxt62q4csiKLh53ccjlW8T8Aoh1 sZZBcibnki+z1i4hdTkBkoap20XgPJWsBxOqHjLb2q31QO3LNX86TXI9bBvQtLjeY6Md 4F0JjbNXc7X077c0pS8Amh9mKQo3qWLpyGdvfOQaJ1BzpsfN8zu5pPCMgTS3fYWpyJOU uRb5pf4uCEoR9WxcAQPccUEMtDXSFbJlWama6bnpkfDuLRYmGHiF+T9A8BlpNnq8V6P8 ZY7g== X-Gm-Message-State: AOAM532TMmaaJPlev9k/wImJW+edtRSbJA2NyOrM8Yqkbo5GnIbRdrVL KxpuI0F1hcAq8vEhRZinlVbV0xARY2STauvw/IU= X-Received: by 2002:a05:6870:89a1:b0:d2:ca93:8797 with SMTP id f33-20020a05687089a100b000d2ca938797mr7428640oaq.112.1650909343234; Mon, 25 Apr 2022 10:55:43 -0700 (PDT) MIME-Version: 1.0 References: <20220424163132.37007-1-makvihas@gmail.com> <20220424163132.37007-4-makvihas@gmail.com> <2e4fa41d-cd06-75e4-17ac-120127fe9b2a@gmail.com> In-Reply-To: <2e4fa41d-cd06-75e4-17ac-120127fe9b2a@gmail.com> From: Vihas Makwana Date: Mon, 25 Apr 2022 23:25:32 +0530 Message-ID: Subject: Re: [PATCH 3/3] staging: r8188eu: fix null check in _rtw_free_mlme_priv To: Pavel Skripkin Cc: Larry Finger , Phillip Potter , Greg Kroah-Hartman , Michael Straube , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Dan Carpenter Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Mon, Apr 25, 2022 at 12:30 AM Pavel Skripkin wrote: > > Hi Vihas, > > On 4/24/22 19:31, Vihas Makwana wrote: > > There's a NULL check on pmlmepriv in rtw_mlme.c:112 which makes no sense > > as rtw_free_mlme_priv_ie_data() dereferences it unconditionally and it > > would have already crashed at this point. > > Fix this by moving rtw_free_mlme_priv_ie_data() inside the check. > > > > Signed-off-by: Vihas Makwana > > That's good catch, but looks like the check is just redundant > > This function is called only from it's wrapper called > rtw_free_mlme_priv() and rtw_free_mlme_priv() is called from 2 places: > > 4 drivers/staging/r8188eu/os_dep/os_intfs.c|531 col 2| > rtw_free_mlme_priv(&padapter->mlmepriv); > 5 drivers/staging/r8188eu/os_dep/os_intfs.c|579 col 2| > rtw_free_mlme_priv(&padapter->mlmepriv); > > _Very_ unlikely that `&padapter->mlmepriv` expression will become NULL. > So I guess either we should remove the check or mark it with the `unlikely()` macro. > > > --- > > drivers/staging/r8188eu/core/rtw_mlme.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c > > index 081c02417..87c754462 100644 > > --- a/drivers/staging/r8188eu/core/rtw_mlme.c > > +++ b/drivers/staging/r8188eu/core/rtw_mlme.c > > @@ -109,12 +109,10 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) > > > > void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) > > { > > - > > - rtw_free_mlme_priv_ie_data(pmlmepriv); > > - > > - if (pmlmepriv) > > + if (pmlmepriv) { > > + rtw_free_mlme_priv_ie_data(pmlmepriv); > > vfree(pmlmepriv->free_bss_buf); > > - > > + } > > } > > > > struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *free_queue) */ > > > > > With regards, > Pavel Skripkin -- Thanks, Vihas