All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <musamaanjum@gmail.com>
To: Mark Brown <broonie@kernel.org>,
	Tian Tao <tiantao6@hisilicon.com>,
	"open list:SPI SUBSYSTEM" <linux-spi@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: musamaanjum@gmail.com, kernel-janitors@vger.kernel.org,
	colin.king@canonical.com, dan.carpenter@oracle.com
Subject: [PATCH] spi: orion: set devdata properly as it is being used later
Date: Fri, 9 Apr 2021 00:57:18 +0500	[thread overview]
Message-ID: <20210408195718.GA3075166@LEGION> (raw)

If device_get_match_data returns NULL, devdata isn't being updated
properly. It is being used later in the function. Both devdata and
spi->devdata should be updated to avoid NULL pointer dereference.

Addresses-Coverity: ("NULL pointer dereference")
Fixes: 0e6521f13c2 ("spi: orion: Use device_get_match_data() helper")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
---
 drivers/spi/spi-orion.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index d02c5c9def20..34b31aba3981 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -676,7 +676,8 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi->dev = &pdev->dev;
 
 	devdata = device_get_match_data(&pdev->dev);
-	spi->devdata = devdata ? devdata : &orion_spi_dev_data;
+	devdata = devdata ? devdata : &orion_spi_dev_data;
+	spi->devdata = devdata;
 
 	spi->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(spi->clk)) {
-- 
2.25.1


             reply	other threads:[~2021-04-08 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 19:57 Muhammad Usama Anjum [this message]
2021-04-09 16:22 ` [PATCH] spi: orion: set devdata properly as it is being used later Mark Brown

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=20210408195718.GA3075166@LEGION \
    --to=musamaanjum@gmail.com \
    --cc=broonie@kernel.org \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=tiantao6@hisilicon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.