[PATCH] scsi: csiostor: use *ptr instead of ptr with sizeof

Deepak R Varma posted 1 patch 2 years, 8 months ago
drivers/scsi/csiostor/csio_mb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] scsi: csiostor: use *ptr instead of ptr with sizeof
Posted by Deepak R Varma 2 years, 8 months ago
The function csio_enqueue_evt() should be passed the actual length of
the event/message so that it can be fully copied over to the event
queue. Use the sizeof(*ptr) to get the real message length instead of
sizeof(ptr).
Issue identified using the noderef,cocci coccinelle semantic patch.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Please note: The change is compile tested only.

 drivers/scsi/csiostor/csio_mb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_mb.c b/drivers/scsi/csiostor/csio_mb.c
index 94810b19e747..4df8a4df4408 100644
--- a/drivers/scsi/csiostor/csio_mb.c
+++ b/drivers/scsi/csiostor/csio_mb.c
@@ -1551,7 +1551,7 @@ csio_mb_isr_handler(struct csio_hw *hw)
 		 * Enqueue event to EventQ. Events processing happens
 		 * in Event worker thread context
 		 */
-		if (csio_enqueue_evt(hw, CSIO_EVT_MBX, mbp, sizeof(mbp)))
+		if (csio_enqueue_evt(hw, CSIO_EVT_MBX, mbp, sizeof(*mbp)))
 			CSIO_INC_STATS(hw, n_evt_drop);
 
 		return 0;
-- 
2.34.1
Re: [PATCH] scsi: csiostor: use *ptr instead of ptr with sizeof
Posted by Deepak R Varma 2 years, 7 months ago
On Thu, Jan 12, 2023 at 05:55:57PM +0530, Deepak R Varma wrote:
> The function csio_enqueue_evt() should be passed the actual length of
> the event/message so that it can be fully copied over to the event
> queue. Use the sizeof(*ptr) to get the real message length instead of
> sizeof(ptr).
> Issue identified using the noderef,cocci coccinelle semantic patch.
> 
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---

Hello,
Requesting a review and feedback comments on this patch proposal please.

Thank you,
./drv

> Please note: The change is compile tested only.
> 
>  drivers/scsi/csiostor/csio_mb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/csiostor/csio_mb.c b/drivers/scsi/csiostor/csio_mb.c
> index 94810b19e747..4df8a4df4408 100644
> --- a/drivers/scsi/csiostor/csio_mb.c
> +++ b/drivers/scsi/csiostor/csio_mb.c
> @@ -1551,7 +1551,7 @@ csio_mb_isr_handler(struct csio_hw *hw)
>  		 * Enqueue event to EventQ. Events processing happens
>  		 * in Event worker thread context
>  		 */
> -		if (csio_enqueue_evt(hw, CSIO_EVT_MBX, mbp, sizeof(mbp)))
> +		if (csio_enqueue_evt(hw, CSIO_EVT_MBX, mbp, sizeof(*mbp)))
>  			CSIO_INC_STATS(hw, n_evt_drop);
>  
>  		return 0;
> -- 
> 2.34.1
> 
> 
>