From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from blu0-omc3-s4.blu0.hotmail.com (blu0-omc3-s4.blu0.hotmail.com [65.55.116.79]) by ozlabs.org (Postfix) with ESMTP id E59A9B70E2 for ; Sat, 12 Feb 2011 21:13:49 +1100 (EST) Message-ID: Content-Type: multipart/alternative; boundary="_e86b3faa-e9d0-4427-b633-237642e46f22_" From: David Binderman To: , Subject: arch/powerpc/kernel/cacheinfo.c: Possible null pointer dereference Date: Sat, 12 Feb 2011 10:08:36 +0000 MIME-Version: 1.0 Cc: linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --_e86b3faa-e9d0-4427-b633-237642e46f22_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello there=2C I just tried out cppcheck-1.47 on the linux-2.6.38-rc4 source code. It said [arch/powerpc/kernel/cacheinfo.c:380]: (error) Possible null pointer derefe= rence: cache - otherwise it is redundant to check if cache is null at line = 382 The source code is WARN_ONCE(cache && cache->level !=3D level=2C "cache level mismatch on lookup (got %d=2C expected %d)\n"=2C cache->level=2C level)=3B if (!cache) I agree with cppcheck. Suggest code rework. Regards David Binderman = --_e86b3faa-e9d0-4427-b633-237642e46f22_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello there=2C

I just tried out cppcheck-1.47 on the linux-2.6.38-rc= 4 source code.

It said

[arch/powerpc/kernel/cacheinfo.c:380]:= (error) Possible null pointer dereference: cache - otherwise it is redunda= nt to check if cache is null at line 382

The source code is

&= nbsp=3B =3B =3B WARN_ONCE(cache &=3B&=3B cache->=3Blevel != =3D level=2C
 =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B "cache level mismatch on lookup (got %d=2C expected %d)\n"=2C=
 =3B =3B =3B =3B =3B =3B =3B =3B = =3B cache->=3Blevel=2C level)=3B

 =3B =3B =3B if (!cac= he)

I agree with cppcheck. Suggest code rework.

Regards
David Binderman

= --_e86b3faa-e9d0-4427-b633-237642e46f22_--