From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD5A15576A; Mon, 8 Jan 2024 17:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="m5ajLXJk" Received: from [192.168.1.54] (unknown [85.30.205.207]) by mail.ispras.ru (Postfix) with ESMTPSA id 286DF40F1DEB; Mon, 8 Jan 2024 17:34:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 286DF40F1DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1704735275; bh=hRWuIE+2qFwu/n+vsFXIu1/VBVgfBej0lvtPdg99qfs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=m5ajLXJk2I7FoFz07Q7nQtLAg9Q/ozw+ilu15EXO/B2u6a8Pr8ygdcZ5hyJeu/Il8 +GWMZW/ucsbpsxOb6kDBQXZRXWoS10dJhiYGJYJtip0UR/DfC/pBJZr8BVoith1o1z yKuvp1wmHWlp6JppHO5aNHTahmvECuquP8M3yc9c= Subject: Re: [PATCH] iphase: Adding a null pointer check To: Andrey Shumilin , 3chas3@gmail.com Cc: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org References: <20231107123600.14529-1-shum.sdl@nppct.ru> From: Alexey Khoroshilov Message-ID: Date: Mon, 8 Jan 2024 20:28:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20231107123600.14529-1-shum.sdl@nppct.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Proposal for subject: atm: iphase: Move check for NULL before derefence in get_desc() On 07.11.2023 15:36, Andrey Shumilin wrote: > The pointer desc_tbl[i].iavcc> is dereferenced on line 195. > Further in the code, it is checked for null on line 204. > It is proposed to add a check before dereferencing the pointer. Line numbers in commit messages are not welcome since they are subject for change and a reader of the message likely has other code at that lines in his version of the file. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Andrey Shumilin > --- > drivers/atm/iphase.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c > index 324148686953..596422fbfacc 100644 > --- a/drivers/atm/iphase.c > +++ b/drivers/atm/iphase.c > @@ -192,6 +192,11 @@ static u16 get_desc (IADEV *dev, struct ia_vcc *iavcc) { > i++; > continue; > } > + if (!(iavcc_r = dev->desc_tbl[i].iavcc)) { > + printk("Fatal err, desc table vcc or skb is NULL\n"); > + i++; > + continue; > + } Error message should be fixed, skb is not check for NULL here. > ltimeout = dev->desc_tbl[i].iavcc->ltimeout; > delta = jiffies - dev->desc_tbl[i].timestamp; > if (delta >= ltimeout) { > > if (!dev->desc_tbl[i].txskb || !(iavcc_r = dev->desc_tbl[i].iavcc)) > printk("Fatal err, desc table vcc or skb is NULL\n"); The existing check should be fixed to check for skb only. -- Alexey