mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Brett Creeley <brett.creeley@amd.com>
Cc: Shannon Nelson <shannon.nelson@amd.com>,
	Dave Jiang <dave.jiang@intel.com>, Jason Gunthorpe <jgg@ziepe.ca>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH next] pds_fwctl: Fix a NULL vs IS_ERR() check in pdsfc_validate_rpc()
Date: Wed, 19 Mar 2025 10:06:29 +0300	[thread overview]
Message-ID: <925355aa-c98b-4fa7-8e49-b97f6d551a86@stanley.mountain> (raw)

The pdsfc_get_operations() function returns error pointers, it doesn't
return NULL.  However, the "ep_info->operations" pointer should be set
to either a valid pointer or NULL because the rest of the driver checks
for that.

Fixes: 804294d75ac5 ("pds_fwctl: add rpc and query support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
---
 drivers/fwctl/pds/main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c
index c0266fc76797..a097fdde0b55 100644
--- a/drivers/fwctl/pds/main.c
+++ b/drivers/fwctl/pds/main.c
@@ -255,6 +255,7 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
 {
 	struct pds_fwctl_query_data_operation *op_entry;
 	struct pdsfc_rpc_endpoint_info *ep_info = NULL;
+	struct pds_fwctl_query_data *operations;
 	struct device *dev = &pdsfc->fwctl.dev;
 	int i;
 
@@ -287,13 +288,14 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
 	/* query and cache this endpoint's operations */
 	mutex_lock(&ep_info->lock);
 	if (!ep_info->operations) {
-		ep_info->operations = pdsfc_get_operations(pdsfc,
-							   &ep_info->operations_pa,
-							   rpc->in.ep);
-		if (!ep_info->operations) {
+		operations = pdsfc_get_operations(pdsfc,
+						  &ep_info->operations_pa,
+						  rpc->in.ep);
+		if (IS_ERR(operations)) {
 			mutex_unlock(&ep_info->lock);
-			return -ENOMEM;
+			return PTR_ERR(operations);
 		}
+		ep_info->operations = operations;
 	}
 	mutex_unlock(&ep_info->lock);
 
-- 
2.47.2


             reply	other threads:[~2025-03-19  7:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19  7:06 Dan Carpenter [this message]
2025-03-19 16:18 ` Nelson, Shannon
2025-03-19 16:26   ` Dan Carpenter
2025-03-19 16:27     ` Jason Gunthorpe
2025-03-19 16:30       ` Nelson, Shannon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=925355aa-c98b-4fa7-8e49-b97f6d551a86@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=brett.creeley@amd.com \
    --cc=dave.jiang@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=shannon.nelson@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®