Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2811147rdb; Mon, 5 Feb 2024 20:24:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOqEbCrLM1gZ7BG5VYqSpr8SzdlEKivJvBR8IFiTq0TfGyVga5JlHy/a+ErhJR4bdrh2kF X-Received: by 2002:a05:6870:808e:b0:219:a2cd:e15c with SMTP id q14-20020a056870808e00b00219a2cde15cmr1790098oab.44.1707193462874; Mon, 05 Feb 2024 20:24:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707193462; cv=pass; d=google.com; s=arc-20160816; b=AN8rIzuaCGI3jZ/aeATTeVfTdkJwwD0orGVndmgj2TUo5cdwSAY6qq/RNNtUYRCRUN x1+63KAj3R8NbqKfJ4fUNIb4tl/mdiG4gMmJ1bK5loDLrgBCSg2h9Q1vDO6/KlK1BJS5 Yt9oPMjqD1ndGLEgO8kZEr2jmgBWVnVFcPrmboB2EQTEXFokxCHcItpzFCWfi7cOimZ2 +IAuYarUa6tONjPIzU7MEz+k3605H1/8z7kMh/wiinOv7fuVy4OxgSTkGnPl/ElBgckx ASHaCEpkJd7g8105Qi+7KPT3L6PAqc0Uu8P+E9JyAHW/TLO6sLY0b0o2OFPSWenZ5Mj+ Sh6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=LzWbdYel3aT7imRL2l+83QFH5wg8/SRc2R/DFZ/44Sg=; fh=bNb9bwVHXa1sdId/EVqdTU0U3+Dj5HPKxGDwa82lRVo=; b=cJbYrLWvmalK8vg7oe5/voMIn2V9XyZZrenC1BdukVZN3n6ncu8X9G/NWNmpDq3rjE 6uIHH1cL8xStpJT6A8XznZkbS5Cli5ZSKSZvxsgayfP7Q0cWOHrbuot1C6oac+01miSr xtMbGzy7ztmS5qX4w1vwEMb1Rk0/wCV8a8jTPd9h6d4AyvYgBikhQD5BUmwUCo/c1RdM UUZ4y/8S+H61DglOMxcjt584bV/g5wXBiSxvy2rh0E12aGeHBu49Thyf14xUXAY1pzNz VyB6n8SWs/HBGGI7bcO3P49lezgcDppLUxNkUgoDev1cC3v/NhmFQsFnmyKN7qNonNmD PRDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DYOPkg05; arc=pass (i=1 spf=pass spfdomain=flex--joychakr.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-54296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCW60SX99FJb39dwLCwb6EYfRVas8UIDWMDMvig8otBL+MpFHnFuTg60NShlWumSflHWKpGbzM7EZOAoVM9PICRJad1xwGDIQZpJGLeFrw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d13-20020a631d0d000000b005cdfcb3908bsi977790pgd.316.2024.02.05.20.24.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 20:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DYOPkg05; arc=pass (i=1 spf=pass spfdomain=flex--joychakr.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-54296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F2E428603C for ; Tue, 6 Feb 2024 04:24:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F579745FE; Tue, 6 Feb 2024 04:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DYOPkg05" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0A27745FA for ; Tue, 6 Feb 2024 04:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707193457; cv=none; b=T1yCJ+pjh52nXyualbUuFBfRSUNi6ZvKy8D8gLg6bHtoDHoBALMkFnUdCRzK6Q2tcMqW+Y8B1SV7IyKDJsnbrTER21Dyg/OowF92w3CWjfkHFvjAV86d4LNX08sNeIDXBsf8Z3RYs+CASyUoItSRvJWWUKIXTs8ucKHi7X0YRq8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707193457; c=relaxed/simple; bh=BBcuUm0bjeZDYFp/nFXayMV+2jioo7Z2SXcSObhkE/0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uCRlELXFAa+sanAo5P2md7ZcqIZ8HEV/3uKcbNeqBetEpNY33G5KTMD60Y9IVsqeG6h0l/5M6ho1Tigr2ru1hVwxWbqJFXu1uXneM6Rmns3dRihfCVLB0rctLn/k7kNbBdNPFqm3x51GPId4dzKL6a6uchFkNVqUwW0mKc9BuwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joychakr.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DYOPkg05; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joychakr.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b9f4a513so8489644276.3 for ; Mon, 05 Feb 2024 20:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707193455; x=1707798255; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=LzWbdYel3aT7imRL2l+83QFH5wg8/SRc2R/DFZ/44Sg=; b=DYOPkg05PyWTDjrw2ceopkyrpCRBIr3yqoXhyFVrCIeW4x4U7h3MEJ/Zf0e2Z3pyIV 2nYAhUGGyApnGZ1oeFsSSzfOiURFOF5Payq7kNWxlC5gpuOm79V4JF7LaEbHj7vHMQZ7 JmM4/ZWyW/J5IpjoK/AOue0Br8/IpR6FRzUEkI3ZpHby/QazfmROxCGnVR9xPa+JzXiV e0UXLEl4oyVrMk9kBn5HEw5eYFgAHnPFOPCNzLAMLFB5GfptyDlScUaC6F1fzJD54+Hi S474GT2f11D1dJIGZF0qGzD67hxY96RmRvRkNHbiBz4N0wP+FWDu9ZZwVC+Ny32RTH9R jChw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707193455; x=1707798255; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LzWbdYel3aT7imRL2l+83QFH5wg8/SRc2R/DFZ/44Sg=; b=W2KZx13o/U8+ZzCLxi6Bm0Raxhx5vbUYaJqo3fnA8tEhE4eb7qXSDnQJQbL6ScPDzU 1EokBKf8oimojwdFuUJOVseTdLc4/f+z2QHbtnQ9ZsXwuDHwHbjKoJqNXEAm+rh9Bx/b 7+WTuvicz8Io2NqKbyAFyTw0gRC0WfCjOigCQ0E6siDPT+RTCAz3t5cISWlzho14CzVg Pr+pCvZEf4JgOeYpJzt3g5BTNqZdS2HFXijIiPb7G3UZ5bGffUrhyDRjmhMOzRqpUhWy vXeAXOBBqDPLy/nDBCgjlD+IM4aKikhv0/nN2ZKiXDfbFmoOI6PC4XJEoYEWoKTPjS8X EBfA== X-Gm-Message-State: AOJu0YzTI+rlvm27XA6BYv0MgzvVVu24CrRMX2WKy732Iu4yssCruNuw 4SyNrtT/9QMUSk7riGI02WfbfVxqPs0QluEx5d5rbYts0nArFAC06L+SsAc7Q/mkNznYTYAqCGC L3e0t4vMToA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a05:6902:2485:b0:dc2:550b:a4f4 with SMTP id ds5-20020a056902248500b00dc2550ba4f4mr162784ybb.1.1707193454844; Mon, 05 Feb 2024 20:24:14 -0800 (PST) Date: Tue, 6 Feb 2024 04:24:08 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240206042408.224138-1-joychakr@google.com> Subject: [PATCH v2] nvmem: rmem: Fix return value of rmem_read() From: Joy Chakraborty To: Srinivas Kandagatla , Greg Kroah-Hartman , Rob Herring , Nicolas Saenz Julienne Cc: linux-kernel@vger.kernel.org, manugautam@google.com, Joy Chakraborty , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" reg_read() callback registered with nvmem core expects an integer error as a return value but rmem_read() returns the number of bytes read, as a result error checks in nvmem core fail even when they shouldn't. Return 0 on success where number of bytes read match the number of bytes requested and a negative error -EINVAL on all other cases. Fixes: 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem") Cc: stable@vger.kernel.org Signed-off-by: Joy Chakraborty --- drivers/nvmem/rmem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c index 752d0bf4445e..a74dfa279ff4 100644 --- a/drivers/nvmem/rmem.c +++ b/drivers/nvmem/rmem.c @@ -46,7 +46,12 @@ static int rmem_read(void *context, unsigned int offset, memunmap(addr); - return count; + if (count != bytes) { + dev_err(priv->dev, "Failed read memory (%d)\n", count); + return -EINVAL; + } + + return 0; } static int rmem_probe(struct platform_device *pdev) -- 2.43.0.594.gd9cf4e227d-goog