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 5C7041F94A for ; Fri, 9 Jan 2026 06:16:39 +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=1767939400; cv=none; b=JzrS9OpBXYL0e0YxExQLwzTzMzOk/Awv4stTxxV5uySZG2DsjvxdWqj/jBrEEbmdg7nfc7WIclWuIvWtETS8/o1iz41sI/xJeewhnHTpQYxxx/27Iv2F61P/1/fZDIQDrJLrZpmMihmVWV5JJsv6ies6PLFEjCJ6zzTi9coE5qY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767939400; c=relaxed/simple; bh=cxWIEq82U1+VTXKSoxLCWyjOYXii7kvOeox7/MbznYw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QAdYnplpvaUwgRC3KHg09MGFG8p7lpee4XTZJ3L0ELI3lauzPSxdkMXTcAVzVrykaYA6ZMcxh77FdHIsgaFrGYrU9dXdFJGzohd2/bb+Y0+goQQZo35wbMD8hRqrICHR0HI+g8lPLobMcJJg92q74DzLQTO7PqzJ+ejjfkM2wYg= 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=uRN1XxfM; 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="uRN1XxfM" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-431048c4068so1574424f8f.1 for ; Thu, 08 Jan 2026 22:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767939398; x=1768544198; 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=RnVeZep7v8MlBogZmNLcKmMrC4cAku9pIYhPOtu1dhQ=; b=uRN1XxfMLMTlUOQOu3AO7qO8nPoPGIeSUL3nTYvpbLtW1vkQg97y2dm6rIeJu/TefW AMLfwVNfMOv7xvG+0Kw//71HnYmGRvzWLO83q84Wz63qZMosRsU5yeWuTR9QWeXev1CM SOrgnkjtwImox0wYR+zL6b/hzn8wCQwcKwKiktBxddI2jSQXcju9r1JyHlMpKex7SOef pXXs0SYaJ1XqDDN71EQDMG5My4IcgVYa8KGxdzEFcPESTT9LAkxVewEU1V5A5GSc9Caj jAvNrs0jbYQ8eP38BCI88zjMl107zXQ39DtMOy7Sut5nQduGlPtuI/ax8nbwO0N194jM UeEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767939398; x=1768544198; 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=RnVeZep7v8MlBogZmNLcKmMrC4cAku9pIYhPOtu1dhQ=; b=SK0klZHRMQ/5A1dhUEhJECZc1t0JGrSRZdisMPWymDjH19RAbiG72Q66xjSVYZifa1 2o/go7M4jmm3Ir7l8rS+UtZMJT2th2X1dVDhfhAD2uLF4b00LrKMpVjqWT+IOLabXj/y Z2dfCfpLmoEEdVfdXex/ZFeSNPzTpvUxo/vfBWFvl2bDHrQ5+N5bequSmiTVWOXwH6Hb mnlwCl9BHu9JI+EeGl3Pu9r1VBj4mMbR5hKKN+Cu48efxQaJZRW6o++hDcIfOq0MtGZo C+CP+DICKvhb+dv6tvzY5ErExzsULTOlDPBZyvMOWOUgwlQetThMf2zPec9QtDyZfFXI bq5g== X-Forwarded-Encrypted: i=1; AJvYcCUzSp7X++Zn6ET2TZk7gKdG4QO9MRNiSCAueaaP3ExPtYYDFTKMbAFBGBcG4E4/WJKpkaugRDQFudjrcZI=@vger.kernel.org X-Gm-Message-State: AOJu0YzkwC4rq/8wqLBrZq1VLrERYHC+PW5wPAIxLAF5ofFqClPgmyIm TQQ0TOi4ovqpgYbu8b9/226xPfYmFBpK8r6QEud9ovXYV1IFLU8ZZWDKR1uuYkDZPe4= X-Gm-Gg: AY/fxX5lBGaX1Y4FNxWK+l4IF6H8voyloCDashLuW0eFu04CMARI/+h6a3cxdHjwsAy P5DcxYBAntsHUT0GgsBdcrh82UlwdZAWgiOa/hVZh+LZO3wohafYOp1h+eMfjiE6ZM2y+mNtSmZ 6h41O68MfPYwHQzFCj3GMPSAxFnw5rPFn1UMShCTcrXKk8Ktkd68lWb5EgFoZh8hUpnRqBtLFc0 ETpBbMYpCnmD0WPAdkFzBdJ9i7N2m+kMetrKTarvW4ZL9HbewT+vcWbdg1Ht7oQzUo8ftgC3hZ5 5OyZZo6Ovj5tnklcibau57qztjjyZFkNhtMLY9j0lBMsoVNgojWSwMOgcuUb2gDM9oWzZG/0MeJ 2u1m0q9tR2MJ/B3/mvv3a+mmKm+K4reekLnIFqOJkU+bfyNsUFKjy+Pv6PY3Vg9o6L/g9HFAJDn P0eHOEjz9z9cas+0OZ X-Google-Smtp-Source: AGHT+IFivkvJjG8RDDGT2kzFg1mBdVrCLyhMl7ynT35itkZqPMT+julOtigzpTGHGKpDuZelQXzGZw== X-Received: by 2002:a05:6000:2886:b0:430:fcbc:dc51 with SMTP id ffacd0b85a97d-432c375ae1dmr11187581f8f.14.1767939397620; Thu, 08 Jan 2026 22:16:37 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ee870sm20434721f8f.36.2026.01.08.22.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 22:16:37 -0800 (PST) Date: Fri, 9 Jan 2026 09:16:34 +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 v2 2/3] staging: rtl8723bs: fix memory leak in rtw_cfg80211_inform_bss() Message-ID: References: <20260108181612.2340796-1-samasth.norway.ananda@oracle.com> <20260108181612.2340796-3-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: <20260108181612.2340796-3-samasth.norway.ananda@oracle.com> On Thu, Jan 08, 2026 at 10:16:10AM -0800, Samasth Norway Ananda wrote: > After successfully allocating buf with kzalloc(), if > cfg80211_inform_bss_frame() returns NULL, the code jumps to the exit > label without freeing buf, causing a memory leak. Add kfree(buf) before > the goto to properly free the buffer in this error case. > > Signed-off-by: Samasth Norway Ananda > --- > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > index 60edeae1cffe..d80e23cfdf8d 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > @@ -314,8 +314,10 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl > bss = cfg80211_inform_bss_frame(wiphy, notify_channel, (struct ieee80211_mgmt *)buf, > len, notify_signal, GFP_ATOMIC); > > - if (unlikely(!bss)) > + if (unlikely(!bss)) { > + kfree(buf); > goto exit; > + } > > cfg80211_put_bss(wiphy, bss); > kfree(buf); This code is so ugly but that's not really related to your patch... Reviewed-by: Dan Carpenter regards, dan carpenter