From patchwork Wed May 18 04:29:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huzaifa Sidhpurwala X-Patchwork-Id: 96119 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CB1FAB6EEB for ; Wed, 18 May 2011 14:30:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932211Ab1EREag (ORCPT ); Wed, 18 May 2011 00:30:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39692 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058Ab1EREag (ORCPT ); Wed, 18 May 2011 00:30:36 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4I4Thk7007140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 18 May 2011 00:29:43 -0400 Received: from babylon.pnq.redhat.com (babylon.pnq.redhat.com [10.65.192.182]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4I4Tfab032674; Wed, 18 May 2011 00:29:42 -0400 Received: by babylon.pnq.redhat.com (Postfix, from userid 500) id 4341423E6D; Wed, 18 May 2011 09:59:41 +0530 (IST) From: Huzaifa Sidhpurwala To: netdev@vger.kernel.org Cc: kaber@trash.net, yoshfuji@linux-ipv6.org, jmorris@namei.org, pekkas@netcore.fi, kuznet@ms2.inr.ac.ru, davem@davemloft.net, Huzaifa Sidhpurwala Subject: [PATCH] Check the value of doi before referencing it Date: Wed, 18 May 2011 09:59:40 +0530 Message-Id: <1305692980-4730-1-git-send-email-huzaifas@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Value of doi is not checked before referencing it. Though this does not cause any null pointer dereference since all the callers of cipso_v4_doi_add check the value of doi before calling the function, but it would be a good programming practice to do so anyways :) Signed-off-by: Huzaifa Sidhpurwala --- net/ipv4/cipso_ipv4.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index a0af7ea..7adc4ea 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -473,10 +473,13 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def, u32 doi_type; struct audit_buffer *audit_buf; - doi = doi_def->doi; - doi_type = doi_def->type; + if (doi_def) { + doi = doi_def->doi; + doi_type = doi_def->type; + } else + goto doi_add_return; - if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN) + if (doi_def->doi == CIPSO_V4_DOI_UNKNOWN) goto doi_add_return; for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) { switch (doi_def->tags[iter]) {