From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 30 22:10:13 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D52B106564A for ; Fri, 30 Dec 2011 22:10:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0FBF98FC12 for ; Fri, 30 Dec 2011 22:10:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBUMACAL003605 for ; Fri, 30 Dec 2011 22:10:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBUMACDl003604; Fri, 30 Dec 2011 22:10:12 GMT (envelope-from gnats) Resent-Date: Fri, 30 Dec 2011 22:10:12 GMT Resent-Message-Id: <201112302210.pBUMACDl003604@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Philippe Saint-Pierre Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76CA51065673 for ; Fri, 30 Dec 2011 22:09:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 6606C8FC0A for ; Fri, 30 Dec 2011 22:09:04 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBUM94Kx026243 for ; Fri, 30 Dec 2011 22:09:04 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id pBUM946P026242; Fri, 30 Dec 2011 22:09:04 GMT (envelope-from nobody) Message-Id: <201112302209.pBUM946P026242@red.freebsd.org> Date: Fri, 30 Dec 2011 22:09:04 GMT From: Philippe Saint-Pierre To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/163724: [PATCH] NULL check before dereference X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2011 22:10:13 -0000 >Number: 163724 >Category: misc >Synopsis: [PATCH] NULL check before dereference >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Dec 30 22:10:12 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Philippe Saint-Pierre >Release: patch made against 8.1 (I think) >Organization: Haiku >Environment: >Description: In the Marvell wifi driver, there are dereferences attempts occuring before the NULL check. >How-To-Repeat: >Fix: Patch included. Basically moves the NULL check to before any dereferences attempts. Patch attached with submission follows: --- mwlhal-orig.c 2011-12-30 12:49:08.807786944 -0500 +++ sys/dev/mwl/mwlhal.c 2011-12-30 12:50:57.787782085 -0500 @@ -1440,15 +1440,20 @@ } sp = &mh->mh_streams[s]; mh->mh_bastreams &= ~(1<public.data[0] = a1; - sp->public.data[1] = a2; - IEEE80211_ADDR_COPY(sp->macaddr, Macaddr); - sp->tid = Tid; - sp->paraminfo = ParamInfo; - sp->setup = 0; - sp->ba_policy = ba_policy; - MWL_HAL_UNLOCK(mh); - return sp != NULL ? &sp->public : NULL; + if (sp != NULL) { + sp->public.data[0] = a1; + sp->public.data[1] = a2; + IEEE80211_ADDR_COPY(sp->macaddr, Macaddr); + sp->tid = Tid; + sp->paraminfo = ParamInfo; + sp->setup = 0; + sp->ba_policy = ba_policy; + MWL_HAL_UNLOCK(mh); + return &sp->public; + } else { + MWL_HAL_UNLOCK(mh); + return NULL; + } } const MWL_HAL_BASTREAM * >Release-Note: >Audit-Trail: >Unformatted: