Received: by 10.213.65.68 with SMTP id h4csp3646078imn; Tue, 10 Apr 2018 02:16:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48HG3S4Xy3W2ltKGsS/1HAtXCyH/E73a5HUjLTYs6HFGE27lmBFc81ZnTFTAK7lBVtmpIhr X-Received: by 2002:a17:902:aa90:: with SMTP id d16-v6mr4397060plr.189.1523351808049; Tue, 10 Apr 2018 02:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523351808; cv=none; d=google.com; s=arc-20160816; b=mLu7TMHTyh2ZqqDy950i7Ftu7Nol1aUOZ8MlubO4COAqHH7MduTmQUeLqaWvkZZToO 6X2lbfzbc5x7zp9CT3CEEIaFcssVk4zwztZyQi1p9jLp+FvNG+XToxg3vBCEPFZtAisZ NGidTYOSiwwQPoRkh/H6a/fVF/Vw6Tux241KoGxYvbOvVgzot8GaKjuHLmCceqbnFrBr lkf5P/JnUwDTofW+Zc8A4qfkeKQ8pTYpQDYOwZs3bR+JXuCcN64irTkfCFPj1YZBWqva 8NRNrTwwfbXCLz1TIbDJtTZpTSbUfls3W9ZghDKRwqNgPA9p6hPiz9LRcZydi4K19urS gHpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=lAl4SJR0Uz0uNDAmQUdzY4ikuxWvhhT2BeJ+G6GKqc4=; b=V5CVPO1Wz+/WYWFY+e4JM2pP5gwku+fO617L0WluBzD5g4WfSP23tAGd4PpUc79oyN avhfPPO7TcnEoaxCHaEifoZk5arL2lPAwcyQI01oY3lxXevOjcE2zGg+b/DvTsf4Gi9t CzhXViHzO2T4T5x0sFy9jrcY4sejvPH4GEpcbXMCD+l8LTbU14GX+WHYioXWG1HZVvY+ ETy+RvNgh9SwW6fmeWnwqm1Bq2+vifOmKoZDQrey4HievFO4IIyHeE9W+Knk8G+Fkjft PTJ6zzD5Arog1Ok0fDbchPu6h1iT6N4DixkSXq+nmtNN/CuG0vIiBY/yVjrAJ+9orKVC DxNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 134si1515956pge.565.2018.04.10.02.16.10; Tue, 10 Apr 2018 02:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122AbeDJJND convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Apr 2018 05:13:03 -0400 Received: from mail.bootlin.com ([62.4.15.54]:42011 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752469AbeDJJNC (ORCPT ); Tue, 10 Apr 2018 05:13:02 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 197DC20857; Tue, 10 Apr 2018 11:13:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 2177621990; Tue, 10 Apr 2018 11:12:21 +0200 (CEST) Date: Tue, 10 Apr 2018 11:12:20 +0200 From: Miquel Raynal To: Abhishek Sahu Cc: Boris Brezillon , Archit Taneja , Richard Weinberger , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Andy Gross , Brian Norris , David Woodhouse Subject: Re: [PATCH 4/9] mtd: nand: qcom: fix null pointer access for erased buffer detection Message-ID: <20180410111220.3873a24c@xps13> In-Reply-To: <1522845745-6624-5-git-send-email-absahu@codeaurora.org> References: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> <1522845745-6624-5-git-send-email-absahu@codeaurora.org> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Abhishek, On Wed, 4 Apr 2018 18:12:20 +0530, Abhishek Sahu wrote: > parse_read_errors can be called with only oob buf also in which > case data_buf will be NULL. If data_buf is NULL, then don’t > treat this page as completely erased in case of ECC uncorrectable > error. > > Signed-off-by: Abhishek Sahu > --- > drivers/mtd/nand/qcom_nandc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c > index 57c16a6..0ebcc55 100644 > --- a/drivers/mtd/nand/qcom_nandc.c > +++ b/drivers/mtd/nand/qcom_nandc.c > @@ -1607,9 +1607,11 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > if (host->bch_enabled) { > erased = (erased_cw & ERASED_CW) == ERASED_CW ? > true : false; Why the parse_read_errors() function could not be called without data_buf when using BCH? Are you sure the situation can only happen without it? Would the following apply here too, with a: if (!data_buf) { erased = false; } else { if (host->bch_enabled) ... else ... } > - } else { > + } else if (data_buf) { > erased = erased_chunk_check_and_fixup(data_buf, > data_len); > + } else { > + erased = false; > } > > if (erased) { > @@ -1652,7 +1654,8 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > max_bitflips = max(max_bitflips, stat); > } > > - data_buf += data_len; > + if (data_buf) > + data_buf += data_len; > if (oob_buf) > oob_buf += oob_len + ecc->bytes; > } Thanks, Miquèl -- Miquel Raynal, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com