Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1570964 > unrolled thread

Re: [PATCH] net: thunderx: avoid dereferencing xcv when NULL

Started byDavid Miller <davem@davemloft.net>
First post2017-01-31 19:20 +0100
Last post2017-01-31 19:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] net: thunderx: avoid dereferencing xcv when NULL David Miller <davem@davemloft.net> - 2017-01-31 19:20 +0100

#1570964 — Re: [PATCH] net: thunderx: avoid dereferencing xcv when NULL

FromDavid Miller <davem@davemloft.net>
Date2017-01-31 19:20 +0100
SubjectRe: [PATCH] net: thunderx: avoid dereferencing xcv when NULL
Message-ID<t5Lc5-3XV-1@gated-at.bofh.it>
From: Vincent Stehlé <vincent.stehle@laposte.net>
Date: Mon, 30 Jan 2017 15:06:43 +0100

> This fixes the following smatch and coccinelle warnings:
> 
>   drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch]
>   drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle]
> 
> Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support")
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Sunil Goutham <sgoutham@cavium.com>

I've applied this, but wow this is some code that needs fixing on a more
fundamental level.

Having a global pointer for a device private and assuming only one instance
of a PCI device ID will ever be probe in a system is really wrong.

This is true even in all known machines or configurations this might
be true.

It leads to exactly the kinds of problems shown here.

Objects should be probed by instance, and if operations need to
be performed on it, a pointer to the software state for that object
instance should be passed around.  Rather than having an implicit
single object.

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web