From patchwork Thu Nov 2 11:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2995 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 490ED3F1F2 for ; Thu, 2 Nov 2023 12:38:39 +0100 (CET) Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32f8c4e9b88sf534207f8f.0 for ; Thu, 02 Nov 2023 04:38:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698925119; cv=pass; d=google.com; s=arc-20160816; b=kTF8BwbCUEE47sBXiCbG+rcWe3HC4E5YaPW+5Jd24bD2HKeWRBGXlrMy4V+BFHuy0e RMXZjF9E6aTexFf+U5rcOVsonYZgAyIuL6GdQ/z30uiAGnZXw/ANDW4pHdbgU8YoJ7U4 bEpwIACmVPAnXbQXDsRcHFMNoUFGlNfOyRxsHiYLDQm7jJCPW/Sr418682/LxowTd2w1 davrOhVfAheMkjQhw+FEYIlStxVWjgrZ/R/JY+hUG85KohwbUXe1pPYAOlTV2//zUR1T 6LEf1T0uTd2Dm1w0muF9BIS+nCRFFq6Rqf8Ph/9IsO4anmxIYqCTHHE6Ao21Cu2JXuFu Hcow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=x5ogi6OvF99JMHmMwnvYPojJ6zxh2TBdPzXvWc9U1Bg=; fh=oE/Vf0Ih7sRms9Q8BiyXGPE19NKiU78mh9OHQ+kcFMM=; b=ZsTvdwEYiJDr5n8iQZAqhNP95SY+c64uoL3YV4Q52l+933mbkDioRl5zcvAoKy/Eut O34CkwX8C6VnC/VsmJ8VEYnTsZW1yZEsA2c7r4wCJaAqtPmX3ejhq1xCtM1OCGdCSTjd 4Bm4o4Q1OFTjN0mZizT+rbGg9GZd+/8OyBHS1IqZP4qFy2BzjZ22XafELrEF/wJw5Bol fmmDVX8HJm2Sy62S82U1s95r3X97Ib79S40/EEia3gofsHkSQPgijlVe8gNsBS1rvr1e Wy4GIAM5jhUXprRSoFc8E0inAOjcBsmIjY9mIpj2HlK89qEcBduwJY6HoEtz+RfVM2CT 8BIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EVZfrISK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1698925119; x=1699529919; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=x5ogi6OvF99JMHmMwnvYPojJ6zxh2TBdPzXvWc9U1Bg=; b=aLxfRN/PH1wkvT8rkz5t+rPpPrhCrBbHk53zxTrOEL+RICvAX7wSlhuxUCxtqvU8qq Bo4e2xDbybBr98MCTzvt6+WH0DXA6f8JCIeR7vQrefl1F3NpKA5c6Ml7ZhAQ7FVNfUYu 4KWPNIsgzXplkrkroaE2F6G3hv4sP9sQeeWN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698925119; x=1699529919; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=x5ogi6OvF99JMHmMwnvYPojJ6zxh2TBdPzXvWc9U1Bg=; b=IDtB8YlwGBhZPSrcKwK6rdhqZMrjgierW+aoBsE0Gasbd6RTTFsphX1AX0cxNwbR7B 8NrC59HDRLaS5TIvxdnsB1o6i9d9bJ3gaTTb0cNbMTPEyzDyhvWgnlgtG/m4ZJHXpoNF OJ+jBn88dK8XeuqVI66cejf4UrA6qolPgixYbMPQDUoQ7ZjE4GaYzJDaIidkLO8be7d/ MjjogSb/x2ggjRipWDW2d9FPWMw9vSSXBc9VxYs/9spV/6F8+x5B5PM6SxaJmcWZmaab y1FMpS6/sNamrTI7kEO4Z5MjwxBhZcnSRAaJy4Uop+94QQsvFWkPjN+1bb8DnLd/8LFE w5Qg== X-Gm-Message-State: AOJu0YxBi8SSVbZvp88PoR+l3AIgIyfy0LUEHvCTIySx191qnfWMIQ4f n5aM2Q/4pe0rQ0vSpuDboUceg+fL9c1w4QhZ X-Google-Smtp-Source: AGHT+IGoryffOd0C6V6n6BPZGidEkz6op2OOWXkbLuhWxJ3TeQEVET/kKq7N0ETKPUCYuzdUDJYxiA== X-Received: by 2002:a5d:550d:0:b0:32d:c792:fcaf with SMTP id b13-20020a5d550d000000b0032dc792fcafmr4797648wrv.26.1698925118639; Thu, 02 Nov 2023 04:38:38 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3110:b0:407:7dee:f38c with SMTP id g16-20020a05600c311000b004077deef38cls156219wmo.2.-pod-prod-00-eu; Thu, 02 Nov 2023 04:38:37 -0700 (PDT) X-Received: by 2002:a05:600c:45cd:b0:407:4701:f9e with SMTP id s13-20020a05600c45cd00b0040747010f9emr9414276wmo.17.1698925117243; Thu, 02 Nov 2023 04:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698925117; cv=none; d=google.com; s=arc-20160816; b=vX3N0gAU549fzRocaLupzyWea9WFxnVYYefBTfmDDthokv91f06OtMng+8mMmnGFGx RjUByRDbjvz3koJ4wkTEyFU2Pr2sq9MexqjxPaYO8+KCyFltgNFX+zmNLQKUjEruV5Bw BXqgjLyBi9JXJ8VBd8DtRz1jQSpe1A/T/uumbfnIqfwytQAYuiGXBvc80KEs6ci/okWU jTGvdsLihFfFrbuuW2uQUGl+dGyn7EEmrzl+P+xbYT9CWDUlMny/evHhl32UCkVtzpPl x8JW5GPbzmbhwecHVFEH75rp/ZAGYpSGkEdhobYI3JmJ+Z/Wymf8WttFs835ZsH/MzpN F7Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Oh4ZnVQs6rqEtyH0BQE7bx6b2vAM5JOZBGdRPaRzgoA=; fh=oE/Vf0Ih7sRms9Q8BiyXGPE19NKiU78mh9OHQ+kcFMM=; b=NigQeIJz04n+z2fX8dNCKWtYo8lGva5HRumrHY6UIloZU1UgvKKsAM0xEy67WcQ7La 0eosQRhTs7Fo1BjlTXcwZBB5m5vTP850IeKax+0I7j4UABdqHEIw2/TdOjBRNQMHvj/Y UgpozybIg4EwTb0FVEAYo+P/PYPhUHfS1or3bpSNeFcwczeqIAwyNLgnC4g5YDuFd9Y4 0tseRb9K3/CpcxmzM9GOLh6Sakcq3ryne16O85smsRLD74GNCxFToUw9mah/qu+LCsTZ RJNO16RiIzZXBYPT8RxK6+z5N3cOtRELCgsfUwEYtD46Ex68+m+TNZQ4Kiv3ipN3P7+g GSbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EVZfrISK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d8-20020a05600c34c800b00405432af064sor538022wmq.3.2023.11.02.04.38.37 for (Google Transport Security); Thu, 02 Nov 2023 04:38:37 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:35d5:b0:403:aced:f7f4 with SMTP id r21-20020a05600c35d500b00403acedf7f4mr6137909wmq.12.1698925116637; Thu, 02 Nov 2023 04:38:36 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. (net-93-150-246-117.cust.dsl.teletu.it. [93.150.246.117]) by smtp.gmail.com with ESMTPSA id m3-20020a05600c4f4300b0040531f5c51asm2625181wmq.5.2023.11.02.04.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 04:38:35 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Michael Trimarchi Subject: [PATCH] mtd: nand: check nand_mtd_to_devnum() argument Date: Thu, 2 Nov 2023 12:38:22 +0100 Message-ID: <20231102113829.58852-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EVZfrISK; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If the "mtd" parameter is NULL, the search will definitely yield a negative result. In that case, it's better to exit immediately. Signed-off-by: Dario Binacchi Reviewed-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/nand.c b/drivers/mtd/nand/raw/nand.c index eacd99c4e275..55c00ac815dd 100644 --- a/drivers/mtd/nand/raw/nand.c +++ b/drivers/mtd/nand/raw/nand.c @@ -41,8 +41,11 @@ int nand_mtd_to_devnum(struct mtd_info *mtd) { int i; + if (!mtd) + return -ENODEV; + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { - if (mtd && get_nand_dev_by_index(i) == mtd) + if (get_nand_dev_by_index(i) == mtd) return i; }