All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: qedf: potential dereference of null pointer
@ 2021-12-16 10:14 Jiasheng Jiang
  2022-01-03  4:58 ` [EXT] " Saurav Kashyap
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jiasheng Jiang @ 2021-12-16 10:14 UTC (permalink / raw)
  To: skashyap, jhasan, GR-QLogic-Storage-Upstream, jejb,
	martin.petersen, linux
  Cc: linux-scsi, linux-kernel, netdev, Jiasheng Jiang

The return value of dma_alloc_coherent() needs to be checked.
To avoid use of null pointer in case of the failure of alloc.

Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/scsi/qedf/qedf_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index b92570a7c309..309e205a8e70 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1415,6 +1415,8 @@ static void qedf_upload_connection(struct qedf_ctx *qedf,
 	 */
 	term_params = dma_alloc_coherent(&qedf->pdev->dev, QEDF_TERM_BUFF_SIZE,
 		&term_params_dma, GFP_KERNEL);
+	if (!term_params)
+		return;
 
 	QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_CONN, "Uploading connection "
 		   "port_id=%06x.\n", fcport->rdata->ids.port_id);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [EXT] [PATCH] scsi: qedf: potential dereference of null pointer
  2021-12-16 10:14 [PATCH] scsi: qedf: potential dereference of null pointer Jiasheng Jiang
@ 2022-01-03  4:58 ` Saurav Kashyap
  2022-01-03 17:12   ` Jakub Kicinski
  2022-01-04  4:05 ` Saurav Kashyap
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Saurav Kashyap @ 2022-01-03  4:58 UTC (permalink / raw)
  To: Jiasheng Jiang, Javed Hasan, GR-QLogic-Storage-Upstream, jejb,
	martin.petersen, linux
  Cc: linux-scsi, linux-kernel, netdev

Hi Jiasheng Jiang,

> -----Original Message-----
> From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Sent: Thursday, December 16, 2021 3:45 PM
> To: Saurav Kashyap <skashyap@marvell.com>; Javed Hasan
> <jhasan@marvell.com>; GR-QLogic-Storage-Upstream <GR-QLogic-Storage-
> Upstream@marvell.com>; jejb@linux.ibm.com; martin.petersen@oracle.com;
> linux@armlinux.org.uk
> Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org;
> netdev@vger.kernel.org; Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Subject: [EXT] [PATCH] scsi: qedf: potential dereference of null pointer
> 
> External Email
> 
> ----------------------------------------------------------------------
> The return value of dma_alloc_coherent() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.
> 
> Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver
> framework.")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/scsi/qedf/qedf_main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index b92570a7c309..309e205a8e70 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -1415,6 +1415,8 @@ static void qedf_upload_connection(struct qedf_ctx
> *qedf,
>  	 */
>  	term_params = dma_alloc_coherent(&qedf->pdev->dev,
> QEDF_TERM_BUFF_SIZE,
>  		&term_params_dma, GFP_KERNEL);
> +	if (!term_params)
> +		return;

<SK> Adding message about failure before returning will help in debugging.

Thanks,
~Saurav
> 
>  	QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_CONN, "Uploading
> connection "
>  		   "port_id=%06x.\n", fcport->rdata->ids.port_id);
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [EXT] [PATCH] scsi: qedf: potential dereference of null pointer
  2022-01-03  4:58 ` [EXT] " Saurav Kashyap
@ 2022-01-03 17:12   ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2022-01-03 17:12 UTC (permalink / raw)
  To: Saurav Kashyap
  Cc: Jiasheng Jiang, Javed Hasan, GR-QLogic-Storage-Upstream, jejb,
	martin.petersen, linux, linux-scsi, linux-kernel, netdev

On Mon, 3 Jan 2022 04:58:41 +0000 Saurav Kashyap wrote:
> > QEDF_TERM_BUFF_SIZE,
> >  		&term_params_dma, GFP_KERNEL);
> > +	if (!term_params)
> > +		return;  
> 
> <SK> Adding message about failure before returning will help in debugging.

Memory allocations produce a pretty detailed splat.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXT] [PATCH] scsi: qedf: potential dereference of null pointer
  2021-12-16 10:14 [PATCH] scsi: qedf: potential dereference of null pointer Jiasheng Jiang
  2022-01-03  4:58 ` [EXT] " Saurav Kashyap
@ 2022-01-04  4:05 ` Saurav Kashyap
  2022-01-05  5:20 ` Martin K. Petersen
  2022-01-10 22:04 ` Martin K. Petersen
  3 siblings, 0 replies; 6+ messages in thread
From: Saurav Kashyap @ 2022-01-04  4:05 UTC (permalink / raw)
  To: Jiasheng Jiang, Javed Hasan, GR-QLogic-Storage-Upstream, jejb,
	martin.petersen, linux
  Cc: linux-scsi, linux-kernel, netdev

HI Jiasheng Jiang,

> -----Original Message-----
> From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Sent: Thursday, December 16, 2021 3:45 PM
> To: Saurav Kashyap <skashyap@marvell.com>; Javed Hasan
> <jhasan@marvell.com>; GR-QLogic-Storage-Upstream <GR-QLogic-Storage-
> Upstream@marvell.com>; jejb@linux.ibm.com; martin.petersen@oracle.com;
> linux@armlinux.org.uk
> Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org;
> netdev@vger.kernel.org; Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Subject: [EXT] [PATCH] scsi: qedf: potential dereference of null pointer
> 
> External Email
> 
> ----------------------------------------------------------------------
> The return value of dma_alloc_coherent() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.
> 
> Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver
> framework.")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/scsi/qedf/qedf_main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index b92570a7c309..309e205a8e70 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -1415,6 +1415,8 @@ static void qedf_upload_connection(struct qedf_ctx
> *qedf,
>  	 */
>  	term_params = dma_alloc_coherent(&qedf->pdev->dev,
> QEDF_TERM_BUFF_SIZE,
>  		&term_params_dma, GFP_KERNEL);
> +	if (!term_params)
> +		return;
> 
>  	QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_CONN, "Uploading
> connection "
>  		   "port_id=%06x.\n", fcport->rdata->ids.port_id);
> --

Acked-by: Saurav Kashyap <skashyap@marvell.com>

Thanks,
~Saurav
> 2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qedf: potential dereference of null pointer
  2021-12-16 10:14 [PATCH] scsi: qedf: potential dereference of null pointer Jiasheng Jiang
  2022-01-03  4:58 ` [EXT] " Saurav Kashyap
  2022-01-04  4:05 ` Saurav Kashyap
@ 2022-01-05  5:20 ` Martin K. Petersen
  2022-01-10 22:04 ` Martin K. Petersen
  3 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2022-01-05  5:20 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: skashyap, jhasan, GR-QLogic-Storage-Upstream, jejb,
	martin.petersen, linux, linux-scsi, linux-kernel, netdev


Jiasheng,

> The return value of dma_alloc_coherent() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.

Applied to 5.17/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qedf: potential dereference of null pointer
  2021-12-16 10:14 [PATCH] scsi: qedf: potential dereference of null pointer Jiasheng Jiang
                   ` (2 preceding siblings ...)
  2022-01-05  5:20 ` Martin K. Petersen
@ 2022-01-10 22:04 ` Martin K. Petersen
  3 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2022-01-10 22:04 UTC (permalink / raw)
  To: Jiasheng Jiang, jejb, skashyap, GR-QLogic-Storage-Upstream,
	jhasan, linux
  Cc: Martin K . Petersen, linux-scsi, linux-kernel, netdev

On Thu, 16 Dec 2021 18:14:49 +0800, Jiasheng Jiang wrote:

> The return value of dma_alloc_coherent() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.
> 
> 

Applied to 5.17/scsi-queue, thanks!

[1/1] scsi: qedf: potential dereference of null pointer
      https://git.kernel.org/mkp/scsi/c/aa7069d840da

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-10 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 10:14 [PATCH] scsi: qedf: potential dereference of null pointer Jiasheng Jiang
2022-01-03  4:58 ` [EXT] " Saurav Kashyap
2022-01-03 17:12   ` Jakub Kicinski
2022-01-04  4:05 ` Saurav Kashyap
2022-01-05  5:20 ` Martin K. Petersen
2022-01-10 22:04 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.