Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547Ab3FDLP7 (ORCPT ); Tue, 4 Jun 2013 07:15:59 -0400 Received: from mail-ob0-f182.google.com ([209.85.214.182]:36422 "EHLO mail-ob0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752633Ab3FDLP5 (ORCPT ); Tue, 4 Jun 2013 07:15:57 -0400 MIME-Version: 1.0 In-Reply-To: <20130603153323.GB20009@thunk.org> References: <1370253616-8173-1-git-send-email-ruslan.bilovol@ti.com> <1370253616-8173-2-git-send-email-ruslan.bilovol@ti.com> <20130603153323.GB20009@thunk.org> Date: Tue, 4 Jun 2013 14:15:57 +0300 X-Google-Sender-Auth: y5usIqAWTWo_2mQTrmPcTiVvbrk Message-ID: Subject: Re: [PATCH 1/2] jbd2: check bh->b_data for NULL in jbd2_journal_get_descriptor_buffer before memset() From: Ruslan Bilovol To: "Theodore Ts'o" , Ruslan Bilovol , adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1815 Lines: 57 Hi Ted, On Mon, Jun 3, 2013 at 6:33 PM, Theodore Ts'o wrote: > On Mon, Jun 03, 2013 at 01:00:15PM +0300, Ruslan Bilovol wrote: >> The memset() doesn't perform any NULL-pointer checking >> before dereferencing passed pointer so this should be >> checked before calling it. > > I can see that __getblk() can return NULL if there is a memory > allocation failure (and is defined to do so), so checking to make sure > bh is not NULL is a good thing to do. > > Have you actually seen a case where bh is non-NULL, but bh->b_data is > NULL? If not, it might be better to do something like this: Yes, this is exactly the situation I observe (bh is non-NULL, but bh->b_data is NULL) > >> bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); > if (!bh) > return NULL; > BUG_ON(!bh->b_data); Is it so critical that we need to stop the kernel here? Can we recover from this state gracefully? Maybe something like this may be better: bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); if (!bh) return NULL; if(!bh->b_data) { WARN_ON(1); return NULL; } Regards, Ruslan > > - Ted > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Best regards, Ruslan Bilvol -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/