lkml.org 
[lkml]   [2019]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging: kpc2000: replace assertion with recovery code
Date
In kpc_dma_transfer, if either priv or ldev is NULL, crashing the
process is excessive and is not needed. Instead of asserting, by
passing the error upstream, the error can be handled.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/staging/kpc2000/kpc_dma/fileops.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c
index cb52bd9a6d2f..1c4633267cc1 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -49,9 +49,11 @@ static int kpc_dma_transfer(struct dev_private_data *priv,
u64 dma_addr;
u64 user_ctl;

- BUG_ON(priv == NULL);
+ if (!priv)
+ return -EINVAL;
ldev = priv->ldev;
- BUG_ON(ldev == NULL);
+ if (!ldev)
+ return -EINVAL;

acd = kzalloc(sizeof(*acd), GFP_KERNEL);
if (!acd) {
--
2.20.1
\
 
 \ /
  Last update: 2019-12-15 19:13    [W:0.049 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site