Received: by 10.213.65.68 with SMTP id h4csp689471imn; Wed, 4 Apr 2018 05:44:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx49d5qIdzJKrIUXatCj3vcYEaf6ADjUuXSoRKxDr28V4UJj4gYDJc27IsyoY1eHmxy5eF1w7 X-Received: by 2002:a17:902:7c8b:: with SMTP id y11-v6mr13352497pll.393.1522845885694; Wed, 04 Apr 2018 05:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522845885; cv=none; d=google.com; s=arc-20160816; b=Y0UctFagJODphCEPKQPA1I9DFl86f6Q6T2tTHoO8UoH+98xYT9ZOAT2VPiDWyPr2+Y Gx3wU460k2W4fElw5nOvyMyLDJjCD7ZKbqFXkF6FkXUfnvKScWZoWZcvAs9tlW7GxrM5 0Ylyo+PDiR/sSJ0Al3jwBu1HOzTazKO09Uj7GW+w9UbSy30NP0O9DpmJ8GVTfHK5wcRj 0DNREJe7FqYp8EKCV2qYN4o+FYgYO0dDf9oKXYcnQ35FSd5iSfqwAZAVTJtvvHTNyNGw K2NKt1XAnEGCqoCA1GZLdjJUvIF4VhlzoI3Z6S1X90/KNnLu1RDFiPg3XTZpQ599eZn2 qCNA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=bi+RK2sHcoKaS5w0gA+X2BDKdA4X3rbDw0aWrdCbUgI=; b=WogHxLFdp9qwiq1ULOiPwPxJo4egdxMvlDaJUf8I5mPq7LJNewfALKR2SJwUrEXrk9 Os8URHpinDnZW3nZsFxIoZQBG38gB02aqovo9DkN9mekbkWaRNuNnH0B2n6YuOX5v/21 oJWujwnAc6LKhZqXl1VrviC7s/0nXWFXk/YPWpsDF+lE5qdFGbbz3bA2Ugkuwxr0vM+L 0yzVFiQRbpJmMjB+tv3rht3JWID2LSz/XnNuRQFMJlWR8aGfHlfY+OJW3W1gCiEbTyfz 8muCF9p8EYVPLHu2cBuBMsGCAOsiixbpaidU4lK93Xx3sBJwGASTeLegdmxpP6msDq3W keKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JepWQMGe; dkim=pass header.i=@codeaurora.org header.s=default header.b=TP4ySqKw; 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 l4si3611620pgp.448.2018.04.04.05.44.31; Wed, 04 Apr 2018 05:44:45 -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=JepWQMGe; dkim=pass header.i=@codeaurora.org header.s=default header.b=TP4ySqKw; 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 S1751463AbeDDMnJ (ORCPT + 99 others); Wed, 4 Apr 2018 08:43:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:40880 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeDDMnG (ORCPT ); Wed, 4 Apr 2018 08:43:06 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4A0F46055B; Wed, 4 Apr 2018 12:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522845786; bh=dxRv2ymqQpVoWR/cIkE2MhhDLRFn3xqwR6NEvOsTDZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JepWQMGem86MxIrdZ/dg57z/G3gHXNQb6IFvcWV4tnCdobyoWbjLsBOD8WoGeuWoB IMtPuoaVCDGks8yzy2xh3OpkBtqEPCFb5BOWAg6exgio3dvoWQJwCSvlROQ5WkVFfm wrYC+jixLE9f8CNI6DpZcrwIvmLHXhUhyw4F34Wc= 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 absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id BED1260C65; Wed, 4 Apr 2018 12:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522845785; bh=dxRv2ymqQpVoWR/cIkE2MhhDLRFn3xqwR6NEvOsTDZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TP4ySqKw1DDUP1RSxv/VDXFAoIv8Mi/6B46FYlNk0rc9ps4Es98PtthCbQ1EFPe1R fObRSC/nhcpWnrXdjZyuq+5vd+SUwHd8NEytRLwYExVcDJK+YpBZeipMAqdZdhiqoM J4ttPVr/pCiPS3JG8YEFx61gelc/zgBQtfXkSSq8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BED1260C65 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Boris Brezillon Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andy Gross , Archit Taneja , Abhishek Sahu Subject: [PATCH 4/9] mtd: nand: qcom: fix null pointer access for erased buffer detection Date: Wed, 4 Apr 2018 18:12:20 +0530 Message-Id: <1522845745-6624-5-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> References: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> 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 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; - } 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; } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation