All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()
Date: Mon, 22 Feb 2021 09:24:59 +0300	[thread overview]
Message-ID: <20210222062459.GM2087@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3108 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   55f62bc873477dae2c45bbbc30b86cf3e0982f3b
commit: 5a6338cce9f4133c478d3b10b300f96dd644379a mailbox: arm_mhuv2: Add driver
config: arm64-randconfig-m031-20210221 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()

vim +/data +702 drivers/mailbox/arm_mhuv2.c

5a6338cce9f413 Viresh Kumar 2020-11-17  674  static irqreturn_t mhuv2_receiver_interrupt(int irq, void *arg)
5a6338cce9f413 Viresh Kumar 2020-11-17  675  {
5a6338cce9f413 Viresh Kumar 2020-11-17  676  	struct mhuv2 *mhu = arg;
5a6338cce9f413 Viresh Kumar 2020-11-17  677  	struct mbox_chan *chan = get_irq_chan_rx(mhu);
5a6338cce9f413 Viresh Kumar 2020-11-17  678  	struct device *dev = mhu->mbox.dev;
5a6338cce9f413 Viresh Kumar 2020-11-17  679  	struct mhuv2_mbox_chan_priv *priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  680  	int ret = IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  681  	void *data;
5a6338cce9f413 Viresh Kumar 2020-11-17  682  
5a6338cce9f413 Viresh Kumar 2020-11-17  683  	if (IS_ERR(chan)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  684  		dev_warn(dev, "Failed to find channel for the rx interrupt\n");
5a6338cce9f413 Viresh Kumar 2020-11-17  685  		return IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  686  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  687  	priv = chan->con_priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  688  
5a6338cce9f413 Viresh Kumar 2020-11-17  689  	/* Read and clear the data first */
5a6338cce9f413 Viresh Kumar 2020-11-17  690  	data = priv->ops->read_data(mhu, chan);
5a6338cce9f413 Viresh Kumar 2020-11-17  691  
5a6338cce9f413 Viresh Kumar 2020-11-17  692  	if (!chan->cl) {
5a6338cce9f413 Viresh Kumar 2020-11-17  693  		dev_warn(dev, "Received data on channel (%u) not currently attached to a mailbox client\n",
5a6338cce9f413 Viresh Kumar 2020-11-17  694  			 priv->ch_wn_idx);
5a6338cce9f413 Viresh Kumar 2020-11-17  695  	} else if (IS_ERR(data)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  696  		dev_err(dev, "Failed to read data: %lu\n", PTR_ERR(data));

"data" is an error pointer.

5a6338cce9f413 Viresh Kumar 2020-11-17  697  	} else {
5a6338cce9f413 Viresh Kumar 2020-11-17  698  		mbox_chan_received_data(chan, data);
5a6338cce9f413 Viresh Kumar 2020-11-17  699  		ret = IRQ_HANDLED;
5a6338cce9f413 Viresh Kumar 2020-11-17  700  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  701  
5a6338cce9f413 Viresh Kumar 2020-11-17 @702  	kfree(data);
                                                ^^^^^^^^^^^
This will crash.

5a6338cce9f413 Viresh Kumar 2020-11-17  703  	return ret;
5a6338cce9f413 Viresh Kumar 2020-11-17  704  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 27144 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()
Date: Mon, 22 Feb 2021 09:24:59 +0300	[thread overview]
Message-ID: <20210222062459.GM2087@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3108 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   55f62bc873477dae2c45bbbc30b86cf3e0982f3b
commit: 5a6338cce9f4133c478d3b10b300f96dd644379a mailbox: arm_mhuv2: Add driver
config: arm64-randconfig-m031-20210221 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()

vim +/data +702 drivers/mailbox/arm_mhuv2.c

5a6338cce9f413 Viresh Kumar 2020-11-17  674  static irqreturn_t mhuv2_receiver_interrupt(int irq, void *arg)
5a6338cce9f413 Viresh Kumar 2020-11-17  675  {
5a6338cce9f413 Viresh Kumar 2020-11-17  676  	struct mhuv2 *mhu = arg;
5a6338cce9f413 Viresh Kumar 2020-11-17  677  	struct mbox_chan *chan = get_irq_chan_rx(mhu);
5a6338cce9f413 Viresh Kumar 2020-11-17  678  	struct device *dev = mhu->mbox.dev;
5a6338cce9f413 Viresh Kumar 2020-11-17  679  	struct mhuv2_mbox_chan_priv *priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  680  	int ret = IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  681  	void *data;
5a6338cce9f413 Viresh Kumar 2020-11-17  682  
5a6338cce9f413 Viresh Kumar 2020-11-17  683  	if (IS_ERR(chan)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  684  		dev_warn(dev, "Failed to find channel for the rx interrupt\n");
5a6338cce9f413 Viresh Kumar 2020-11-17  685  		return IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  686  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  687  	priv = chan->con_priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  688  
5a6338cce9f413 Viresh Kumar 2020-11-17  689  	/* Read and clear the data first */
5a6338cce9f413 Viresh Kumar 2020-11-17  690  	data = priv->ops->read_data(mhu, chan);
5a6338cce9f413 Viresh Kumar 2020-11-17  691  
5a6338cce9f413 Viresh Kumar 2020-11-17  692  	if (!chan->cl) {
5a6338cce9f413 Viresh Kumar 2020-11-17  693  		dev_warn(dev, "Received data on channel (%u) not currently attached to a mailbox client\n",
5a6338cce9f413 Viresh Kumar 2020-11-17  694  			 priv->ch_wn_idx);
5a6338cce9f413 Viresh Kumar 2020-11-17  695  	} else if (IS_ERR(data)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  696  		dev_err(dev, "Failed to read data: %lu\n", PTR_ERR(data));

"data" is an error pointer.

5a6338cce9f413 Viresh Kumar 2020-11-17  697  	} else {
5a6338cce9f413 Viresh Kumar 2020-11-17  698  		mbox_chan_received_data(chan, data);
5a6338cce9f413 Viresh Kumar 2020-11-17  699  		ret = IRQ_HANDLED;
5a6338cce9f413 Viresh Kumar 2020-11-17  700  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  701  
5a6338cce9f413 Viresh Kumar 2020-11-17 @702  	kfree(data);
                                                ^^^^^^^^^^^
This will crash.

5a6338cce9f413 Viresh Kumar 2020-11-17  703  	return ret;
5a6338cce9f413 Viresh Kumar 2020-11-17  704  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 27144 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Viresh Kumar <viresh.kumar@linaro.org>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Jassi Brar <jaswinder.singh@linaro.org>,
	Tushar Khandelwal <tushar.khandelwal@arm.com>
Subject: drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()
Date: Mon, 22 Feb 2021 09:24:59 +0300	[thread overview]
Message-ID: <20210222062459.GM2087@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3050 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   55f62bc873477dae2c45bbbc30b86cf3e0982f3b
commit: 5a6338cce9f4133c478d3b10b300f96dd644379a mailbox: arm_mhuv2: Add driver
config: arm64-randconfig-m031-20210221 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR()

vim +/data +702 drivers/mailbox/arm_mhuv2.c

5a6338cce9f413 Viresh Kumar 2020-11-17  674  static irqreturn_t mhuv2_receiver_interrupt(int irq, void *arg)
5a6338cce9f413 Viresh Kumar 2020-11-17  675  {
5a6338cce9f413 Viresh Kumar 2020-11-17  676  	struct mhuv2 *mhu = arg;
5a6338cce9f413 Viresh Kumar 2020-11-17  677  	struct mbox_chan *chan = get_irq_chan_rx(mhu);
5a6338cce9f413 Viresh Kumar 2020-11-17  678  	struct device *dev = mhu->mbox.dev;
5a6338cce9f413 Viresh Kumar 2020-11-17  679  	struct mhuv2_mbox_chan_priv *priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  680  	int ret = IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  681  	void *data;
5a6338cce9f413 Viresh Kumar 2020-11-17  682  
5a6338cce9f413 Viresh Kumar 2020-11-17  683  	if (IS_ERR(chan)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  684  		dev_warn(dev, "Failed to find channel for the rx interrupt\n");
5a6338cce9f413 Viresh Kumar 2020-11-17  685  		return IRQ_NONE;
5a6338cce9f413 Viresh Kumar 2020-11-17  686  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  687  	priv = chan->con_priv;
5a6338cce9f413 Viresh Kumar 2020-11-17  688  
5a6338cce9f413 Viresh Kumar 2020-11-17  689  	/* Read and clear the data first */
5a6338cce9f413 Viresh Kumar 2020-11-17  690  	data = priv->ops->read_data(mhu, chan);
5a6338cce9f413 Viresh Kumar 2020-11-17  691  
5a6338cce9f413 Viresh Kumar 2020-11-17  692  	if (!chan->cl) {
5a6338cce9f413 Viresh Kumar 2020-11-17  693  		dev_warn(dev, "Received data on channel (%u) not currently attached to a mailbox client\n",
5a6338cce9f413 Viresh Kumar 2020-11-17  694  			 priv->ch_wn_idx);
5a6338cce9f413 Viresh Kumar 2020-11-17  695  	} else if (IS_ERR(data)) {
5a6338cce9f413 Viresh Kumar 2020-11-17  696  		dev_err(dev, "Failed to read data: %lu\n", PTR_ERR(data));

"data" is an error pointer.

5a6338cce9f413 Viresh Kumar 2020-11-17  697  	} else {
5a6338cce9f413 Viresh Kumar 2020-11-17  698  		mbox_chan_received_data(chan, data);
5a6338cce9f413 Viresh Kumar 2020-11-17  699  		ret = IRQ_HANDLED;
5a6338cce9f413 Viresh Kumar 2020-11-17  700  	}
5a6338cce9f413 Viresh Kumar 2020-11-17  701  
5a6338cce9f413 Viresh Kumar 2020-11-17 @702  	kfree(data);
                                                ^^^^^^^^^^^
This will crash.

5a6338cce9f413 Viresh Kumar 2020-11-17  703  	return ret;
5a6338cce9f413 Viresh Kumar 2020-11-17  704  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27144 bytes --]

             reply	other threads:[~2021-02-22  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  6:24 Dan Carpenter [this message]
2021-02-22  6:24 ` drivers/mailbox/arm_mhuv2.c:702 mhuv2_receiver_interrupt() error: 'data' dereferencing possible ERR_PTR() Dan Carpenter
2021-02-22  6:24 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-02-21 19:46 kernel test robot

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=20210222062459.GM2087@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /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.