* [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference
@ 2019-12-15 16:14 Aditya Pakki
2019-12-16 8:43 ` Markus Elfring
2019-12-17 0:28 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Aditya Pakki @ 2019-12-15 16:14 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, Chas Williams, linux-atm-general, netdev, linux-kernel
In fore200e_send and fore200e_close, the pointers from the arguments
are dereferenced in the variable declaration block and then checked
for NULL. The patch fixes these issues by avoiding NULL pointer
dereferences.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/atm/fore200e.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index f1a500205313..8fbd36eb8941 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -1414,12 +1414,14 @@ fore200e_open(struct atm_vcc *vcc)
static void
fore200e_close(struct atm_vcc* vcc)
{
- struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
struct fore200e_vcc* fore200e_vcc;
+ struct fore200e* fore200e;
struct fore200e_vc_map* vc_map;
unsigned long flags;
ASSERT(vcc);
+ fore200e = FORE200E_DEV(vcc->dev);
+
ASSERT((vcc->vpi >= 0) && (vcc->vpi < 1<<FORE200E_VPI_BITS));
ASSERT((vcc->vci >= 0) && (vcc->vci < 1<<FORE200E_VCI_BITS));
@@ -1464,10 +1466,10 @@ fore200e_close(struct atm_vcc* vcc)
static int
fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
{
- struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
- struct fore200e_vcc* fore200e_vcc = FORE200E_VCC(vcc);
+ struct fore200e* fore200e;
+ struct fore200e_vcc* fore200e_vcc;
struct fore200e_vc_map* vc_map;
- struct host_txq* txq = &fore200e->host_txq;
+ struct host_txq* txq;
struct host_txq_entry* entry;
struct tpd* tpd;
struct tpd_haddr tpd_haddr;
@@ -1480,9 +1482,18 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
unsigned char* data;
unsigned long flags;
- ASSERT(vcc);
- ASSERT(fore200e);
- ASSERT(fore200e_vcc);
+ if (!vcc)
+ return -EINVAL;
+
+ fore200e = FORE200E_DEV(vcc->dev);
+ fore200e_vcc = FORE200E_VCC(vcc);
+
+ if (!fore200e)
+ return -EINVAL;
+
+ txq = &fore200e->host_txq;
+ if (!fore200e_vcc)
+ return -EINVAL;
if (!test_bit(ATM_VF_READY, &vcc->flags)) {
DPRINTK(1, "VC %d.%d.%d not ready for tx\n", vcc->itf, vcc->vpi, vcc->vpi);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference
2019-12-15 16:14 [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference Aditya Pakki
@ 2019-12-16 8:43 ` Markus Elfring
2019-12-17 0:28 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2019-12-16 8:43 UTC (permalink / raw)
To: Aditya Pakki, linux-atm-general, netdev
Cc: linux-kernel, kernel-janitors, Chas Williams, Kangjie Lu
> The patch fixes these issues by avoiding NULL pointer dereferences.
I suggest to choose a better wording for this change description.
Will the tag “Fixes” become helpful here?
…
> +++ b/drivers/atm/fore200e.c
…
> @@ -1480,9 +1482,18 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
…
> + fore200e = FORE200E_DEV(vcc->dev);
> + fore200e_vcc = FORE200E_VCC(vcc);
> +
> + if (!fore200e)
> + return -EINVAL;
> +
> + txq = &fore200e->host_txq;
> + if (!fore200e_vcc)
> + return -EINVAL;
>
> if (!test_bit(ATM_VF_READY, &vcc->flags)) {
…
Can the following adjustment be nicer?
+ fore200e_vcc = FORE200E_VCC(vcc);
+ if (!fore200e_vcc)
+ return -EINVAL;
+
+ fore200e = FORE200E_DEV(vcc->dev);
+ if (!fore200e)
+ return -EINVAL;
+
+ txq = &fore200e->host_txq;
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference
2019-12-15 16:14 [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference Aditya Pakki
2019-12-16 8:43 ` Markus Elfring
@ 2019-12-17 0:28 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-12-17 0:28 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, 3chas3, linux-atm-general, netdev, linux-kernel
From: Aditya Pakki <pakki001@umn.edu>
Date: Sun, 15 Dec 2019 10:14:51 -0600
> In fore200e_send and fore200e_close, the pointers from the arguments
> are dereferenced in the variable declaration block and then checked
> for NULL. The patch fixes these issues by avoiding NULL pointer
> dereferences.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Applied to net-next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-17 0:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-15 16:14 [PATCH] fore200e: Fix incorrect checks of NULL pointer dereference Aditya Pakki
2019-12-16 8:43 ` Markus Elfring
2019-12-17 0:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).