[PATCH RFC] gpib: hp82335: check the register mapping before requesting IRQ

Slavin Liu posted 1 patch 2 weeks ago
drivers/gpib/hp_82335/hp82335.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH RFC] gpib: hp82335: check the register mapping before requesting IRQ
Posted by Slavin Liu 2 weeks ago
Stop attach on mapping failure before board reset or register access.
The existing detach path handles the reserved region and private state.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: 76319a9d234f ("staging: gpib: Add hp82335x GPIB driver")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 drivers/gpib/hp_82335/hp82335.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpib/hp_82335/hp82335.c b/drivers/gpib/hp_82335/hp82335.c
index b7544b3c15c6..b1ef3dbdcdab 100644
--- a/drivers/gpib/hp_82335/hp82335.c
+++ b/drivers/gpib/hp_82335/hp82335.c
@@ -290,6 +290,8 @@ static int hp82335_attach(struct gpib_board *board, const struct gpib_board_conf
 	}
 	hp_priv->raw_iobase = upper_iomem_base;
 	tms_priv->mmiobase = ioremap(upper_iomem_base, hp82335_upper_iomem_size);
+	if (!tms_priv->mmiobase)
+		return -ENOMEM;
 
 	retval = request_irq(config->ibirq, hp82335_interrupt, 0, DRV_NAME, board);
 	if (retval) {
Re: [PATCH RFC] gpib: hp82335: check the register mapping before requesting IRQ
Posted by Greg KH 2 weeks ago
On Fri, Sep 11, 2026 at 02:09:27PM +0800, Slavin Liu wrote:
> Stop attach on mapping failure before board reset or register access.
> The existing detach path handles the reserved region and private state.
> 
> Detected by static analysis and reviewed with AI-assisted source auditing.
> 
> Fixes: 76319a9d234f ("staging: gpib: Add hp82335x GPIB driver")
> Assisted-by: LLM
> Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
> ---
>  drivers/gpib/hp_82335/hp82335.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpib/hp_82335/hp82335.c b/drivers/gpib/hp_82335/hp82335.c
> index b7544b3c15c6..b1ef3dbdcdab 100644
> --- a/drivers/gpib/hp_82335/hp82335.c
> +++ b/drivers/gpib/hp_82335/hp82335.c
> @@ -290,6 +290,8 @@ static int hp82335_attach(struct gpib_board *board, const struct gpib_board_conf
>  	}
>  	hp_priv->raw_iobase = upper_iomem_base;
>  	tms_priv->mmiobase = ioremap(upper_iomem_base, hp82335_upper_iomem_size);
> +	if (!tms_priv->mmiobase)
> +		return -ENOMEM;

You just leaked memory :(