From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE65D2980A8 for ; Thu, 18 Dec 2025 07:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766042093; cv=none; b=fUjU0bl1Uag8cGGhojm98yP2RunQegZLSU3/3O9Z2adHZdOhWLDsCD8fGCO9RKMLfh2hTwoxzoC+NlNpk3sDlY53itSQJqypkx6lpxi5tA1a4k4QPfPWHOONWygJQQKUh809QCueq2msrhdf+rDiUNO2CwuozxJyV3AKHY4Mt80= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766042093; c=relaxed/simple; bh=zeNhLloIHb7V/wRaam3m0I9gFl5CNMbitd46J1Bklq0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m6VqQ9+jEnSNeswKhBSH/COZSXkyFqfns3Uz3gNOYBKtkAuXGmvYAgkJtqQyx+5jC+7OFSjJ/x1GwBNlqlkWZI1ahYSsFLJMSUV2UXgY+bZ2j1w2qkvhU5UqyOxSHN7QVqAJ9hrO1glPwlWNUG/jnP8ohcSCiPNus8/viXnIZf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zRtJpob8; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zRtJpob8" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-42e2e77f519so131439f8f.2 for ; Wed, 17 Dec 2025 23:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766042090; x=1766646890; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+0+BcFYuJnIT5Gs4sLCThmt9C1DYxR9HC3E5rP7Q8/k=; b=zRtJpob8TH2jiYSvBGy6UYluLiWvc4EcS6SdfG5yYy1hcDjm3hFkbVPdocVRxPvV2P jLF6w4dtfhwCPbRuJJz0OwkEh5O/7n9iRHbhT+OXKBbuz7d6n+Z3sH+HU39Yw0m1QL8+ nX3IS17TT8DSYMCDxeX5f3JmJN/+7cEiIk+8KVeJusyni+5admsKIHCSBLcee+3YOkTi iRMVfpNFZDANDVq7/3du1vaxsUtslGrTeJGz6hIl4jngqyPHjIwnqeDRhT7lTji0SDmR Qivfh0Zwj97LQ9979YsuB8H774AbaFAhIVsywrSEGl5GN8p+uTmDdyR/KU5GoWi+J1io cXLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766042090; x=1766646890; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+0+BcFYuJnIT5Gs4sLCThmt9C1DYxR9HC3E5rP7Q8/k=; b=cJKJwGioPbIUh4bzIwSNGkjIhapZkvWUbrz0X070kM8/KSk15MsAoAxgCOauOjiqnD zp/jyjOJM8ibDtkn8QsYlmpubUKsp/IVOnjvwKjoAujAcBugiHKuWbQo4pc543EvPCgA obsB4qo1THcZC2k7QqL4bzTJ+oogOuf3vkNCxVr4hPWGDneomrQcFvLRHnNR1tKZI9NW 3vJbrpZcTJd5Lw1MgNzIsfPOSonDPJt91mKd4vMaG2kcYmZSD5pX6Tnu+51pWpRSH3Ko ekMQGWtBNGFVp1n2J41DsLGJBPpUO0feZNOmzBuBa33tHnAEhe9gcinIemoVL9ULdPGk 8q9g== X-Forwarded-Encrypted: i=1; AJvYcCXakxvEfp7G1Rn/vX/AfAp3Tl0uY+0Tc40RHL67ELjNNwkxwEsGPhJHT+ZWz7vvmteCFiPjy+qIMhCm/s8=@vger.kernel.org X-Gm-Message-State: AOJu0YxikYwB8YpnwPoBXclAEmbOvnvn3lm02NjB5jjsHqxZBAoe0hOg WBTUqJrpq/PCgm9rgAm1NGX2nX9T2LUp2SKIgNZ5zaeo+T2H3cPvaHuEo96DexDUbqI= X-Gm-Gg: AY/fxX5yYIpxvdmxdiIdroC/lXo5U6aV/VZyGxGWbuJbtgCL5FfhIH08O4vRQfT1MwF yLDFI6GTvW2D8l6E6WO5DKTvZBtCMwE7OTDd1Md0QQ3ABRSohOs894pe6jQSXVUfzrcshUvvjam Rpt8QdetN5fnVVj44c3vZnmZygZ7cZB3+zlfSTwqWeZeeiSvPgLFnqR760/SCcHN0MXSc0lQg/W iN6oPencC9PHkekTMKVYob14U5vslaOf/w9rhluYNwOk0iYgFOAiyhQ8pn+MtxsCpGL2RNVK4Hr 7SZh0ZaPteSr+M3zu63f157Soo6GH4on0IVJZbafi0JlfOdnYKUnV+lb4NYNSWN6logT5kbED3s Z7R2U5nQeZZPActITUBE+SR97mmWY0Zt5hxLv44wXKA07Y2J+syrzx9AjrlZx8dVLW3bd43kpM3 7CpJ3uFhXSRVLCZd2G X-Google-Smtp-Source: AGHT+IEAWD/Hey5CzPkHXCwKI7+ThamQbiYueMminqdn5DAPJfrvb/dTOJDxn0MiX0EQTJMNdhcygA== X-Received: by 2002:a05:6000:2909:b0:42b:3ad7:fdd3 with SMTP id ffacd0b85a97d-42fb44ba20cmr22198021f8f.18.1766042089937; Wed, 17 Dec 2025 23:14:49 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324498f8f1sm3222838f8f.21.2025.12.17.23.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 23:14:49 -0800 (PST) Date: Thu, 18 Dec 2025 10:14:46 +0300 From: Dan Carpenter To: Samasth Norway Ananda Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] staging: rtl8723bs: fix firmware memory leak on error path Message-ID: References: <20251218011414.1781294-1-samasth.norway.ananda@oracle.com> <20251218011414.1781294-2-samasth.norway.ananda@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251218011414.1781294-2-samasth.norway.ananda@oracle.com> On Wed, Dec 17, 2025 at 05:14:11PM -0800, Samasth Norway Ananda wrote: > Fix memory leak where firmware is not released on error paths in > rtl8723b_FirmwareDownload(). > > After successfully calling request_firmware(), if the firmware size > check fails or if kmemdup() fails, the code jumps to the exit label > without calling release_firmware(), causing a memory leak. > > Add a release_fw label to properly free the firmware in these er:qror > cases. Also add an error message when firmware size exceeds the limit to > help with debugging. > > Signed-off-by: Samasth Norway Ananda > --- > drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c > index 57c83f332e74..0eae624a36f0 100644 > --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c > +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c > @@ -345,14 +345,16 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw) > } > > if (fw->size > FW_8723B_SIZE) { > + pr_err("Firmware size exceed, max: %d, actual: %zu\n", > + FW_8723B_SIZE, fw->size); > rtStatus = _FAIL; > - goto exit; > + goto release_fw; > } > > pFirmware->fw_buffer_sz = kmemdup(fw->data, fw->size, GFP_KERNEL); > if (!pFirmware->fw_buffer_sz) { > rtStatus = _FAIL; > - goto exit; > + goto release_fw; > } > > pFirmware->fw_length = fw->size; > @@ -415,6 +417,10 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw) > goto fwdl_stat; > > fwdl_stat: > + goto exit; What's the point of this nonsense label the just does another goto? regards, dan carpenter > + > +release_fw: > + release_firmware(fw); > > exit: > kfree(pFirmware->fw_buffer_sz); > -- > 2.50.1 >