From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 56EA51BC41 for ; Thu, 18 Dec 2025 07:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766041969; cv=none; b=no3cHaoUWs+3+YcWUUWBGM8UIVfJujwqP1CYw4uVTAIV73SSosEXIxflnjciqPd+AYtKbax3Js2kmSBz1w4KSkFL4EZiOMPY5Xk+0zoJuX+3xggnjgH2fBdO63g3s4JA0Mu0WPI/BcLRG6QQeiFimG6CCDeexOhoT91TjzOP/Go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766041969; c=relaxed/simple; bh=havm6bqjb6lnBnYAm3GPOpMNKkte4SuOAffY/lS98Y4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kx/s1FQYAKA96ULUx8kn+fL02xfb86k/HqdH8CtCqPO4qV8Q5R5LiSFuyO9MzAf3aavD8DNlLKySxXhw4/mwE+BpWM6FIrtgbgzb4ai4lggmyDe3HlC0dBpwxgiH455rp1zNK+8hqSAf2Fvv8t0EtRc6LuSOGRyIkThNuDQ/OS4= 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=evm+leRi; arc=none smtp.client-ip=209.85.128.45 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="evm+leRi" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-477632d9326so1657835e9.1 for ; Wed, 17 Dec 2025 23:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766041966; x=1766646766; 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=B9yVXoB/OYBdhrkXc0cF/nS6Lq/SPgGWFM6QmRezHSI=; b=evm+leRiU51OD4uPAJdtJVTWg3S+1SwVwS13yBicwdjSABJImCxnt40R96wMBMQsj3 n+i/hmiouIGjwuzkHrloqZ+8X0uFR68y6UBgQUOe0IeXazNbEI6ip7/tWpiDq9NTTVXe ja3QUjglVo2+0TRyIMMxaYyAZI+RAfrrxnEF/CSGncaSGsyjMuIo+ut2HMkiRQnFgJ8p TUQBbTjZumBqZMvymK9yRlK2EXsJs4Z+QJu9F09oZEfUWSHi15Lk9GGORurej8i5y+Yt 960hz05mQ7lSXq9/bANXzjYMnnIaTD+eibIvpmhpsLYL2EwTQ0sG3lqkH0H4Guxbs467 MjQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766041966; x=1766646766; 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=B9yVXoB/OYBdhrkXc0cF/nS6Lq/SPgGWFM6QmRezHSI=; b=jxvg9hmw+W4xUvurqa6J2DrX8I3Fh1u0r72dVrogkhfoDALG4Uu87ewwlNpHudYSXY pr4BuV03bUu7nPeS5eFFugFjxOTdN6QhF5RR8VD3rLj3Xkt+KLmb2bhfWyDp7TUL4KUL 6bqIe6DaWFmQZx5P0U87VJVxQTQZ77RzFw8zH9zHurrCu1vga4JxkfkKT9vPjGedK3ui jbTcUQ2OAq1utiBsYuA/JCu/vyHzRTZ48UaG17/NuBdf/9ERRbtMxJsvHUfyvFIUQsG+ 3BWKzSimScMIJJA+47t9oh1evQWsWdahnKYjeDD1hPDtRggthVMBLRszB0MC4Sl5uFhP 3Sqw== X-Forwarded-Encrypted: i=1; AJvYcCXYokQHMoLyWrGEZoHH/1qVMUzWuvQbgvq0C7uLmd2d4s0EXQFS+hA65RqJf9g2Hhuqg9PgMBx4jIjywGg=@vger.kernel.org X-Gm-Message-State: AOJu0YyNd46h0CAuGz3zkFIZetLPTH7q9HNe6gSGF6ofTFsG34apN/nF FNKdtBbyiAPAXX/6Vb8L6fsNP3aBMD8KY/fpARA4dQUfLSKp1SmIXOK93s/uRP0q1PE= X-Gm-Gg: AY/fxX4aQKxPKbaZnkKGiFLJZGCADBkC2ZthTFBDURp68vFGeYMdpEQ4/lm7LCE+5zN +4+Lve1t7cQ4lGRLBMJifgvFAYpGpnPTyWz5QOr9MQuiqTktIp6KT9kzt2qNLncO5SV/qxQObsa B7AAAfuJE38+0N07J6kekWlqW8og/V6NR0OdEn6b+w9Ww7gg/tX29F7zAZ4PJvHbk6C/68eF0yD Tajz1PlpikHol+lqHg+qqj5xzTZdP53VO/F6Bnof5c+YQ23yvx2dp3dLNfYhA+d1vZT3wDm1sg2 QXmLY/sxNadv3rwn1PAsRE1YGIVYgik46Snq56xU+s8fF3mbc4C4ElSDvZxok7DHpfIiqbUmyFV XVV3agRt1kU3mOXINv8C+RIeTuhgeKNQb9MBcxJwvOF3orboXlKrEIPpWzBUfrD+tN8AEtQ+Hji 4lZpkrJ/Y5Paw+gJFVi8nKUIaLx2A= X-Google-Smtp-Source: AGHT+IHo5/JDwq31zF6KkHTuBIz8aun+WZrAHtozzUrszrWr/Eth7iMknLzyeFJBQFaf75it8rPdxg== X-Received: by 2002:a05:600d:14:b0:475:da1a:5418 with SMTP id 5b1f17b1804b1-47a8f9a825amr167451685e9.1.1766041965589; Wed, 17 Dec 2025 23:12:45 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3aed4c7sm8304385e9.18.2025.12.17.23.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 23:12:45 -0800 (PST) Date: Thu, 18 Dec 2025 10:12:41 +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 4/4] staging: rtl8723bs: check return value of rtw_wdev_alloc() Message-ID: References: <20251218011414.1781294-1-samasth.norway.ananda@oracle.com> <20251218011414.1781294-5-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-5-samasth.norway.ananda@oracle.com> On Wed, Dec 17, 2025 at 05:14:14PM -0800, Samasth Norway Ananda wrote: > Add missing error check for rtw_wdev_alloc() in rtw_sdio_if1_init(). > > rtw_wdev_alloc() can fail with -ENOMEM when wiphy_new() or rtw_zmalloc() > fails, or with other negative error codes when wiphy_register() fails. > Without checking the return value, initialization continues even when > wireless device allocation fails, potentially leaving the adapter in an > inconsistent state. > > Jump to the error cleanup path when rtw_wdev_alloc() fails to ensure > proper resource cleanup and prevent use of an incompletely initialized > adapter. > > Signed-off-by: Samasth Norway Ananda > --- > drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c > index 1d0239eef114..432bc6aa1d90 100644 > --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c > +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c > @@ -296,7 +296,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct > if (rtw_init_drv_sw(padapter) == _FAIL) This call to rtw_init_drv_sw() does a number of allocations. > goto free_hal_data; > > - rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj)); > + if (rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj))) > + goto free_hal_data; So this goto should free them as well. I have a blog about how to write cleanup code in a systematic way. https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/ regards, dan carpenter