Linux-PCI Archive on lore.kernel.org
 help / color / Atom feed
* pcie-rockchip-ep.c coverity issue #1437163
@ 2020-10-27 16:16 Bjorn Helgaas
  2020-10-27 16:37 ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2020-10-27 16:16 UTC (permalink / raw)
  To: Shawn Lin; +Cc: linux-pci

Hi Shawn,

Please take a look at this issue reported by Coverity:

332 static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
333 {
334        struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
335        struct rockchip_pcie *rockchip = &ep->rockchip;
336        u16 flags;
337
338        flags = rockchip_pcie_read(rockchip,
339                                   ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
340                                   ROCKCHIP_PCIE_EP_MSI_CTRL_REG);

CID 1437163 (#2 of 2): Operands don't affect result
(CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: flags &
(65536UL /* 1UL << 16 */) is always 0 regardless of the values of its
operands. This occurs as the logical operand of !.

341        if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
342                return -EINVAL;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pcie-rockchip-ep.c coverity issue #1437163
  2020-10-27 16:16 pcie-rockchip-ep.c coverity issue #1437163 Bjorn Helgaas
@ 2020-10-27 16:37 ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2020-10-27 16:37 UTC (permalink / raw)
  To: Shawn Lin; +Cc: linux-pci

On Tue, Oct 27, 2020 at 11:16:38AM -0500, Bjorn Helgaas wrote:
> Hi Shawn,
> 
> Please take a look at this issue reported by Coverity:
> 
> 332 static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
> 333 {
> 334        struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
> 335        struct rockchip_pcie *rockchip = &ep->rockchip;
> 336        u16 flags;
> 337
> 338        flags = rockchip_pcie_read(rockchip,
> 339                                   ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
> 340                                   ROCKCHIP_PCIE_EP_MSI_CTRL_REG);
> 
> CID 1437163 (#2 of 2): Operands don't affect result
> (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: flags &
> (65536UL /* 1UL << 16 */) is always 0 regardless of the values of its
> operands. This occurs as the logical operand of !.
> 
> 341        if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
> 342                return -EINVAL;

The same issue also occurs in rockchip_pcie_ep_send_msi_irq()
(Coverity issue #143765 for that one).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pcie-rockchip-ep.c coverity issue #1437163
  2020-12-23 21:04 ` Bjorn Helgaas
@ 2020-12-24  0:55   ` Shawn Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Shawn Lin @ 2020-12-24  0:55 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: shawn.lin, linux-pci, Krzysztof Wilczynski


在 2020/12/24 5:04, Bjorn Helgaas 写道:
> [+cc Krzysztof]
> 
> On Wed, Oct 28, 2020 at 08:34:45AM +0800, Shawn Lin wrote:
>> On 2020/10/28 0:16, Bjorn Helgaas wrote:
>>> Hi Shawn,
>>>
>>> Please take a look at this issue reported by Coverity:
>>>
>>> 332 static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
>>> 333 {
>>> 334        struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
>>> 335        struct rockchip_pcie *rockchip = &ep->rockchip;
>>> 336        u16 flags;
>>> 337
>>> 338        flags = rockchip_pcie_read(rockchip,
>>> 339                                   ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
>>> 340                                   ROCKCHIP_PCIE_EP_MSI_CTRL_REG);
>>>
>>> CID 1437163 (#2 of 2): Operands don't affect result
>>> (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: flags &
>>> (65536UL /* 1UL << 16 */) is always 0 regardless of the values of its
>>> operands. This occurs as the logical operand of !.
>>>
>>> 341        if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
>>> 342                return -EINVAL;
>>
>> Actually it should be BIT(0) instead of BIT(16),
>> I will fix it, thanks.
> 
> Just a quick reminder about this and the similar issue in
> rockchip_pcie_ep_send_msi_irq().
> 
> Your response above didn't seem to make it to the archive, so maybe
> your patch to fix it also got lost?
> 
> Krzysztof also pointed out that rockchip_pcie_read() returns u32,
> while flags is only u16.
> 

Thanks for reminder. I didn't notice my previous patch hadn't arrived at
the archive but I just sent again a few minutes ago.

> Bjorn
> 
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pcie-rockchip-ep.c coverity issue #1437163
       [not found] <60a290a9-678b-b08d-25b4-8299f2f2c916@rock-chips.com>
@ 2020-12-23 21:04 ` Bjorn Helgaas
  2020-12-24  0:55   ` Shawn Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2020-12-23 21:04 UTC (permalink / raw)
  To: Shawn Lin; +Cc: linux-pci, Krzysztof Wilczynski

[+cc Krzysztof]

On Wed, Oct 28, 2020 at 08:34:45AM +0800, Shawn Lin wrote:
> On 2020/10/28 0:16, Bjorn Helgaas wrote:
> > Hi Shawn,
> > 
> > Please take a look at this issue reported by Coverity:
> > 
> > 332 static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
> > 333 {
> > 334        struct rockchip_pcie_ep *ep = epc_get_drvdata(epc);
> > 335        struct rockchip_pcie *rockchip = &ep->rockchip;
> > 336        u16 flags;
> > 337
> > 338        flags = rockchip_pcie_read(rockchip,
> > 339                                   ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
> > 340                                   ROCKCHIP_PCIE_EP_MSI_CTRL_REG);
> > 
> > CID 1437163 (#2 of 2): Operands don't affect result
> > (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: flags &
> > (65536UL /* 1UL << 16 */) is always 0 regardless of the values of its
> > operands. This occurs as the logical operand of !.
> > 
> > 341        if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
> > 342                return -EINVAL;
> 
> Actually it should be BIT(0) instead of BIT(16),
> I will fix it, thanks.

Just a quick reminder about this and the similar issue in
rockchip_pcie_ep_send_msi_irq().

Your response above didn't seem to make it to the archive, so maybe
your patch to fix it also got lost?

Krzysztof also pointed out that rockchip_pcie_read() returns u32,
while flags is only u16.

Bjorn

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 16:16 pcie-rockchip-ep.c coverity issue #1437163 Bjorn Helgaas
2020-10-27 16:37 ` Bjorn Helgaas
     [not found] <60a290a9-678b-b08d-25b4-8299f2f2c916@rock-chips.com>
2020-12-23 21:04 ` Bjorn Helgaas
2020-12-24  0:55   ` Shawn Lin

Linux-PCI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pci/0 linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ https://lore.kernel.org/linux-pci \
		linux-pci@vger.kernel.org
	public-inbox-index linux-pci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git