Received: by 10.192.165.156 with SMTP id m28csp1618290imm; Thu, 12 Apr 2018 00:01:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zT0NN2szblQiRwfL21NUXTnEXDKtMPF/4lfefNDRWLVXj5TbSP1v3IP3yINRGkEu6j9Da X-Received: by 10.98.59.139 with SMTP id w11mr6608502pfj.96.1523516467884; Thu, 12 Apr 2018 00:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523516467; cv=none; d=google.com; s=arc-20160816; b=IpQmyWpdmgbUDvv/kC1S+yw7Rp/tU9SgMnQQF5tS6BClrzirmnqsG1DrJnevPqYN0j akloOfg6olOpq/MKWwHnhREpUNzo05xSMcinbeBycpaLvxbOLLKJpuzUO/BY9WXh1U/c x4T3oZ+O1KzOLuSOLasuTuwC7W0ulcHaWB/bmJJcJdluzWMV6tMQ4wapWLroz3fgJsHw wd6JMbfZuc9p+WyJZ88t5FIxmXd6uv3ZzqurEVsNgZYqmvlQHCRZ6NXyBIAMMbMl02PT kaxPOyd5NAihtXUlNNwXLLw5Zmt1wnPqOfkm0n8RY0BLNBArH0lI5en+vP+t4uct0FzU x/qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=hfqeyhtzaK8tAPyXvDvk01BKsYGJp7F8npNZfBP1eVI=; b=BR6kMmbL6OWFS7NSNvsU7fXKyZtVcwOkYkbWQcPamLnq3Y1C9P4kPmIyPz+lTAYDg+ Lhq4H32cCG7QX0e296E9x8xvRpjy4P9kXmvI0S7TaQjfnr9aAKK0UwfI3oCfgeVPcDIY QxFyon8ZGfhIZgNdSb714vBwC5rdcQrmqEMtHedXWMWRzEW38d3lwh4aq3khL+JF3Z8A RGgsvU7spbIByWFAWoqhXcz+Mr9trvHD0zzK3jBTAR49wBH+xvyhLEylZkcDPpunQeP3 effDLOQ7MhjTfbejoFBSHmm0N1xMNMjKt5/Zv6dOmcw9EdtYhqP26Ac3ifNQPEvL2xZv RagQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=m+vkwvQ3; dkim=pass header.i=@codeaurora.org header.s=default header.b=m+vkwvQ3; 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 z1-v6si2667864plb.101.2018.04.12.00.00.30; Thu, 12 Apr 2018 00:01:07 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=m+vkwvQ3; dkim=pass header.i=@codeaurora.org header.s=default header.b=m+vkwvQ3; 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 S1752865AbeDLGyU (ORCPT + 99 others); Thu, 12 Apr 2018 02:54:20 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37292 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752350AbeDLGyS (ORCPT ); Thu, 12 Apr 2018 02:54:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DD8A960F91; Thu, 12 Apr 2018 06:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523516057; bh=qNKqfIavya/UQxjjVW+ID+cBh57BIQS06nt48Hi3SCg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=m+vkwvQ31btLBAXUFeZwqQx3U+X5XLhat+895I927nGA03LkABh3aZjI1kFearHqa 1yPqLaUqa0Nekq2QFZVM4NSS/ldxETKeUJGTNHNgyAsy/kjcHvM34G4X4OpNK3gDtX 4TgqJbOzx1xPJn3d0UHC7PAuv15FwNssYvWoKWYE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id E448F60807; Thu, 12 Apr 2018 06:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523516057; bh=qNKqfIavya/UQxjjVW+ID+cBh57BIQS06nt48Hi3SCg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=m+vkwvQ31btLBAXUFeZwqQx3U+X5XLhat+895I927nGA03LkABh3aZjI1kFearHqa 1yPqLaUqa0Nekq2QFZVM4NSS/ldxETKeUJGTNHNgyAsy/kjcHvM34G4X4OpNK3gDtX 4TgqJbOzx1xPJn3d0UHC7PAuv15FwNssYvWoKWYE= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 12 Apr 2018 12:24:16 +0530 From: Abhishek Sahu To: Miquel Raynal 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 In-Reply-To: <20180410111220.3873a24c@xps13> References: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> <1522845745-6624-5-git-send-email-absahu@codeaurora.org> <20180410111220.3873a24c@xps13> Message-ID: X-Sender: absahu@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-10 14:42, Miquel Raynal wrote: > 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? > host->bch_enabled case is different where controller itself tells regarding erased page in status register. > Would the following apply here too, with a: > erased_chunk_check_and_fixup will be used only for 4 bit RS ECC code in which there is no support from HW for erased page detection and we need to check few data bytes value. Thanks, Abhishek > 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