From: Colin King <hidden> Date: 2016-12-20 10:08:38
From: Colin Ian King <redacted>
rmi_dev is currently being dereferenced before it null checked, so we
have a potential null pointer dereference issue with this. Fix this
by dereferencing rmi_dev after a null check has been performed.
Fixes CoverityScan CID 1391218 ("Dereference before null check")
Signed-off-by: Colin Ian King <redacted>
---
drivers/input/rmi4/rmi_f03.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -164,7 +164,7 @@ static int rmi_f03_config(struct rmi_function *fn)staticintrmi_f03_attention(structrmi_function*fn,unsignedlong*irq_bits){structrmi_device*rmi_dev=fn->rmi_dev;-structrmi_driver_data*drvdata=dev_get_drvdata(&rmi_dev->dev);+structrmi_driver_data*drvdata;structf03_data*f03=dev_get_drvdata(&fn->dev);u16data_addr=fn->fd.data_base_addr;constu8ob_len=f03->rx_queue_length*RMI_F03_OB_SIZE;
@@ -178,6 +178,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)if(!rmi_dev)return-ENODEV;+drvdata=dev_get_drvdata(&rmi_dev->dev);if(drvdata->attn_data.data){/* First grab the data passed by the transport device */if(drvdata->attn_data.size<ob_len){
Hi Colin,
On Tue, Dec 20, 2016 at 10:07:50AM +0000, Colin King wrote:
From: Colin Ian King <redacted>
rmi_dev is currently being dereferenced before it null checked, so we
have a potential null pointer dereference issue with this. Fix this
by dereferencing rmi_dev after a null check has been performed.
Fixes CoverityScan CID 1391218 ("Dereference before null check")
I'd rather we removed the NULL check instead. As far as I can see it
can't even be NULL.
quoted hunk
Signed-off-by: Colin Ian King <redacted>
---
drivers/input/rmi4/rmi_f03.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -164,7 +164,7 @@ static int rmi_f03_config(struct rmi_function *fn)staticintrmi_f03_attention(structrmi_function*fn,unsignedlong*irq_bits){structrmi_device*rmi_dev=fn->rmi_dev;-structrmi_driver_data*drvdata=dev_get_drvdata(&rmi_dev->dev);+structrmi_driver_data*drvdata;structf03_data*f03=dev_get_drvdata(&fn->dev);u16data_addr=fn->fd.data_base_addr;constu8ob_len=f03->rx_queue_length*RMI_F03_OB_SIZE;
@@ -178,6 +178,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)if(!rmi_dev)return-ENODEV;+drvdata=dev_get_drvdata(&rmi_dev->dev);if(drvdata->attn_data.data){/* First grab the data passed by the transport device */if(drvdata->attn_data.size<ob_len){
From: Colin Ian King <hidden> Date: 2016-12-21 14:42:41
On 20/12/16 21:22, Dmitry Torokhov wrote:
Hi Colin,
On Tue, Dec 20, 2016 at 10:07:50AM +0000, Colin King wrote:
quoted
From: Colin Ian King <redacted>
rmi_dev is currently being dereferenced before it null checked, so we
have a potential null pointer dereference issue with this. Fix this
by dereferencing rmi_dev after a null check has been performed.
Fixes CoverityScan CID 1391218 ("Dereference before null check")
I'd rather we removed the NULL check instead. As far as I can see it
can't even be NULL.
quoted
Signed-off-by: Colin Ian King <redacted>
---
drivers/input/rmi4/rmi_f03.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -164,7 +164,7 @@ static int rmi_f03_config(struct rmi_function *fn)staticintrmi_f03_attention(structrmi_function*fn,unsignedlong*irq_bits){structrmi_device*rmi_dev=fn->rmi_dev;-structrmi_driver_data*drvdata=dev_get_drvdata(&rmi_dev->dev);+structrmi_driver_data*drvdata;structf03_data*f03=dev_get_drvdata(&fn->dev);u16data_addr=fn->fd.data_base_addr;constu8ob_len=f03->rx_queue_length*RMI_F03_OB_SIZE;
@@ -178,6 +178,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)if(!rmi_dev)return-ENODEV;+drvdata=dev_get_drvdata(&rmi_dev->dev);if(drvdata->attn_data.data){/* First grab the data passed by the transport device */if(drvdata->attn_data.size<ob_len){