Skip to contentSkip to conversation

drm/bochs: Drop manual put on probe error path

PATCH In review Myeonghun Pak 3 participants 10 messages Apr 24 – May 8

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bochs: Drop manual put on probe error path

bochs_pci_probe() allocates the DRM device with devm_drm_dev_alloc(), which registers a devres action to drop the initial DRM device reference on driver detach or probe failure.

The error path currently calls drm_dev_put() manually. If probe then returns an error, devres will run the registered release action and put the same device again, after the first put may already have released it.

Return the probe error directly and let devres own the final put.

---
 drivers/gpu/drm/tiny/bochs.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/tiny/bochs.c +3 -7
index 222e4ae1ab..5d8dc5efec 100644
@@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
 
 	ret = pcim_enable_device(pdev);
 	if (ret)
-		goto err_free_dev;
+		return ret;
 
 	pci_set_drvdata(pdev, dev);
 
 	ret = bochs_load(bochs);
 	if (ret)
-		goto err_free_dev;
+		return ret;
 
 	ret = drm_dev_register(dev, 0);
 	if (ret)
-		goto err_free_dev;
+		return ret;
 
 	drm_client_setup(dev, NULL);
 
 	return ret;
-
-err_free_dev:
-	drm_dev_put(dev);
-	return ret;
 }
 
 static void bochs_pci_remove(struct pci_dev *pdev)
Signature · 1 line
2.39.5
#1 lore raw

Hi,

please add fixes tags to all these patches you're sending. You also need to CC stable so that they can be backported easily. Also list the AI you're using to find and create these patches.

Best regards
Thomas

Am 24.04.26 um 14:34 schrieb Myeonghun Pak:

Quoted 48 lines

bochs_pci_probe() allocates the DRM device with devm_drm_dev_alloc(), which registers a devres action to drop the initial DRM device reference on driver detach or probe failure.

The error path currently calls drm_dev_put() manually. If probe then returns an error, devres will run the registered release action and put the same device again, after the first put may already have released it.

Return the probe error directly and let devres own the final put.

---
  drivers/gpu/drm/tiny/bochs.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/tiny/bochs.c +3 -7
index 222e4ae1ab..5d8dc5efec 100644
@@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
 
  	ret = pcim_enable_device(pdev);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	pci_set_drvdata(pdev, dev);
 
  	ret = bochs_load(bochs);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	ret = drm_dev_register(dev, 0);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	drm_client_setup(dev, NULL);
 
  	return ret;
-
-err_free_dev:
-	drm_dev_put(dev);
-	return ret;
  }
 
  static void bochs_pci_remove(struct pci_dev *pdev)
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#2 lore raw

Hi Thomas,

Thank you for your reply. I will ensure that the requested Fixes tag and stable CC are included in the next patch I send.

Regarding your request for information about AI usage and how the issue was identified:

- This issue was identified during our ongoing static-analysis research while reviewing kernel code.
1 <https://mail.google.com/mail/u/0/#all/%23thread-f:1863355320119932959>
- Specifically, it was found by an experimental static analysis tool that we are currently developing. The tool is not public yet, so I prefer not to disclose further project details at this stage.

- AI was used only for cross-review, not as the primary means of finding or fixing the bug.
- I manually reviewed the code and verified the issue before sending the patch.

I will incorporate your requests and this additional context, and then resend the modified patch.

Thank you.

Myeonghun Pak

2026년 4월 24일 (금) 오후 10:25, Thomas Zimmermann <[email protected]>님이 작성:

Quoted 71 lines

Hi,

please add fixes tags to all these patches you're sending. You also need to CC stable so that they can be backported easily. Also list the AI you're using to find and create these patches.

Best regards
Thomas

Am 24.04.26 um 14:34 schrieb Myeonghun Pak:

drivers/gpu/drm/tiny/bochs.c static int bochs_pci_probe(struct pci_dev *pdev,

Quoted 20 lines

bochs_pci_probe() allocates the DRM device with devm_drm_dev_alloc(), which registers a devres action to drop the initial DRM device reference on driver detach or probe failure.

The error path currently calls drm_dev_put() manually. If probe then returns an error, devres will run the registered release action and put the same device again, after the first put may already have released it.

Return the probe error directly and let devres own the final put.

---
  drivers/gpu/drm/tiny/bochs.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/tiny/bochs.c +0 -0
index 222e4ae1ab..5d8dc5efec 100644
@@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev *pdev,

const struct pci_device_id *ent

Quoted 18 lines
drivers/gpu/drm/tiny/bochs.c +3 -3
      ret = pcim_enable_device(pdev);
      if (ret)
-             goto err_free_dev;
+             return ret;
 
      pci_set_drvdata(pdev, dev);
 
      ret = bochs_load(bochs);
      if (ret)
-             goto err_free_dev;
+             return ret;
 
      ret = drm_dev_register(dev, 0);
      if (ret)
-             goto err_free_dev;
+             return ret;
 

drivers/gpu/drm/tiny/bochs.c static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent · line 781

Quoted 10 lines
drivers/gpu/drm/tiny/bochs.c +0 -4
      drm_client_setup(dev, NULL);
 
      return ret;
-
-err_free_dev:
-     drm_dev_put(dev);
-     return ret;
  }
 
  static void bochs_pci_remove(struct pci_dev *pdev)

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

maintainer Reviewed-by
#3 lore raw

Hi

Am 24.04.26 um 15:40 schrieb Myeonghun Pak:

Quoted 14 lines

Hi Thomas,

Thank you for your reply. I will ensure that the requested |Fixes| tag and |stable| CC are included in the next patch I send.

Regarding your request for information about AI usage and how the issue was identified:

* This issue was identified during our ongoing static-analysis

    research while reviewing kernel code.
    1
    <https://mail.google.com/mail/u/0/#all/%23thread-f:1863355320119932959>

* Specifically, it was found by an experimental static analysis tool that we are currently developing. The tool is not public yet, so I prefer not to disclose further project details at this stage.

Quoted 6 lines

* AI was used only for cross-review, not as the primary means of finding or fixing the bug.
* I manually reviewed the code and verified the issue before sending the patch.

I will incorporate your requests and this additional context, and then resend the modified patch.

Thanks a lot.

Best regards
Thomas

Quoted 85 lines

Thank you.

Myeonghun Pak

2026년 4월 24일 (금) 오후 10:25, Thomas Zimmermann <[email protected]>님이 작성:

    Hi,

    please add fixes tags to all these patches you're sending. You
    also need
    to CC stable so that they can be backported easily. Also list the AI
    you're using to find and create these patches.

    Best regards
    Thomas

    Am 24.04.26 um 14:34 schrieb Myeonghun Pak:
    > bochs_pci_probe() allocates the DRM device with
    devm_drm_dev_alloc(),
    > which registers a devres action to drop the initial DRM device
    reference
    > on driver detach or probe failure.
    >
    > The error path currently calls drm_dev_put() manually. If probe then
    > returns an error, devres will run the registered release action
    and put
    > the same device again, after the first put may already have
    released it.
    >
    > Return the probe error directly and let devres own the final put.
    >
    > Signed-off-by: Myeonghun Pak <[email protected]>
    > ---
    >   drivers/gpu/drm/tiny/bochs.c | 10 +++-------
    >   1 file changed, 3 insertions(+), 7 deletions(-)
    >
    > diff --git a/drivers/gpu/drm/tiny/bochs.c
    b/drivers/gpu/drm/tiny/bochs.c
    > index 222e4ae1ab..5d8dc5efec 100644
    > --- a/drivers/gpu/drm/tiny/bochs.c
    > +++ b/drivers/gpu/drm/tiny/bochs.c
    > @@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev
    *pdev, const struct pci_device_id *ent
    >
    >       ret = pcim_enable_device(pdev);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       pci_set_drvdata(pdev, dev);
    >
    >       ret = bochs_load(bochs);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       ret = drm_dev_register(dev, 0);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       drm_client_setup(dev, NULL);
    >
    >       return ret;
    > -
    > -err_free_dev:
    > -     drm_dev_put(dev);
    > -     return ret;
    >   }
    >
    >   static void bochs_pci_remove(struct pci_dev *pdev)

    -- 
    --
    Thomas Zimmermann
    Graphics Driver Developer
    SUSE Software Solutions Germany GmbH
    Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
    <http://www.suse.com>
    GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG
    Nürnberg)
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#4 lore raw

Thanks for the explanation.

I see your point now. My patch treated uart_add_one_port() failure as a fatal
probe failure, but the current code is intentionally trying to keep the driver
alive so that other MAX3100 ports can still be available even if one port cannot
be instantiated.

Please drop this patch. I will not pursue this direction.

Thanks,
Myeonghun

2026년 4월 24일 (금) 오후 11:59, Thomas Zimmermann <[email protected]>님이 작성:

Quoted 134 lines

Hi

Am 24.04.26 um 15:40 schrieb Myeonghun Pak:

Quoted 5 lines

Hi Thomas,

Thank you for your reply. I will ensure that the requested |Fixes| tag and |stable| CC are included in the next patch I send.

Quoted 7 lines

Regarding your request for information about AI usage and how the issue was identified:

* This issue was identified during our ongoing static-analysis

    research while reviewing kernel code.
    1
    <

https://mail.google.com/mail/u/0/#all/%23thread-f:1863355320119932959>

Quoted 11 lines

* Specifically, it was found by an experimental static analysis tool that we are currently developing. The tool is not public yet, so I prefer not to disclose further project details at this stage.

* AI was used only for cross-review, not as the primary means of finding or fixing the bug.
* I manually reviewed the code and verified the issue before sending the patch.

I will incorporate your requests and this additional context, and then resend the modified patch.

Thanks a lot.

Best regards
Thomas

Quoted 19 lines

Thank you.

Myeonghun Pak

2026년 4월 24일 (금) 오후 10:25, Thomas Zimmermann
<[email protected]>님이 작성:

Hi,

please add fixes tags to all these patches you're sending. You also need
to CC stable so that they can be backported easily. Also list the AI you're using to find and create these patches.

Best regards
Thomas

Quoted 8 lines

Am 24.04.26 um 14:34 schrieb Myeonghun Pak:
> bochs_pci_probe() allocates the DRM device with devm_drm_dev_alloc(),
> which registers a devres action to drop the initial DRM device reference
> on driver detach or probe failure.
>
> The error path currently calls drm_dev_put() manually. If probe

then

Quoted 49 lines
Quoted 1 line

returns an error, devres will run the registered release action

    and put
    > the same device again, after the first put may already have
    released it.
    >
    > Return the probe error directly and let devres own the final put.
    >
    > Signed-off-by: Myeonghun Pak <[email protected]>
    > ---
    >   drivers/gpu/drm/tiny/bochs.c | 10 +++-------
    >   1 file changed, 3 insertions(+), 7 deletions(-)
    >
    > diff --git a/drivers/gpu/drm/tiny/bochs.c
    b/drivers/gpu/drm/tiny/bochs.c
    > index 222e4ae1ab..5d8dc5efec 100644
    > --- a/drivers/gpu/drm/tiny/bochs.c
    > +++ b/drivers/gpu/drm/tiny/bochs.c
    > @@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev
    *pdev, const struct pci_device_id *ent
    >
    >       ret = pcim_enable_device(pdev);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       pci_set_drvdata(pdev, dev);
    >
    >       ret = bochs_load(bochs);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       ret = drm_dev_register(dev, 0);
    >       if (ret)
    > -             goto err_free_dev;
    > +             return ret;
    >
    >       drm_client_setup(dev, NULL);
    >
    >       return ret;
    > -
    > -err_free_dev:
    > -     drm_dev_put(dev);
    > -     return ret;
    >   }
    >
    >   static void bochs_pci_remove(struct pci_dev *pdev)

    --
Quoted 10 lines
    --
    Thomas Zimmermann
    Graphics Driver Developer
    SUSE Software Solutions Germany GmbH
    Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
    <http://www.suse.com>
    GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG
    Nürnberg)

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

#5 lore raw

Hi

Am 30.04.26 um 15:52 schrieb Myeonghun Pak:

Quoted 8 lines

Thanks for the explanation.

I see your point now. My patch treated uart_add_one_port() failure as a fatal probe failure, but the current code is intentionally trying to keep the driver alive so that other MAX3100 ports can still be available even if one port cannot be instantiated.

Please drop this patch. I will not pursue this direction.

Why? The was patch was good AFAICT. It's just missing a Fixes tag.

Best regards
Thomas

Quoted 151 lines

Thanks,
Myeonghun

2026년 4월 24일 (금) 오후 11:59, Thomas Zimmermann <[email protected]>님이 작성:

Hi

Am 24.04.26 um 15:40 schrieb Myeonghun Pak:
> Hi Thomas,
>
> Thank you for your reply. I will ensure that the requested |Fixes| tag
> and |stable| CC are included in the next patch I send. >
> Regarding your request for information about AI usage and how the > issue was identified:
>
>   * This issue was identified during our ongoing static-analysis >     research while reviewing kernel code.
>     1
>
 <https://mail.google.com/mail/u/0/#all/%23thread-f:1863355320119932959>
>   * Specifically, it was found by an experimental static analysis tool
>     that we are currently developing. The tool is not public yet, so I
>     prefer not to disclose further project details at this stage. >
>   * AI was used only for cross-review, not as the primary means of >     finding or fixing the bug.
>   * I manually reviewed the code and verified the issue before sending
>     the patch.
>
> I will incorporate your requests and this additional context, and then
> resend the modified patch.

Thanks a lot.

Best regards
Thomas

>
> Thank you.
>
> Myeonghun Pak
>
>
> 2026년 4월 24일 (금) 오후 10:25, Thomas Zimmermann
> <[email protected]>님이 작성:
>
>     Hi,
>
>     please add fixes tags to all these patches you're sending. You >     also need
>     to CC stable so that they can be backported easily. Also list the AI
>     you're using to find and create these patches.
>
>     Best regards
>     Thomas
>
>     Am 24.04.26 um 14:34 schrieb Myeonghun Pak:
>     > bochs_pci_probe() allocates the DRM device with
>     devm_drm_dev_alloc(),
>     > which registers a devres action to drop the initial DRM device >     reference
>     > on driver detach or probe failure.
>     >
>     > The error path currently calls drm_dev_put() manually. If probe then
>     > returns an error, devres will run the registered release action
>     and put
>     > the same device again, after the first put may already have >     released it.
>     >
>     > Return the probe error directly and let devres own the final put.
>     >
>     > Signed-off-by: Myeonghun Pak <[email protected]>
>     > ---
>     >   drivers/gpu/drm/tiny/bochs.c | 10 +++-------
>     >   1 file changed, 3 insertions(+), 7 deletions(-) >     >
>     > diff --git a/drivers/gpu/drm/tiny/bochs.c
>     b/drivers/gpu/drm/tiny/bochs.c
>     > index 222e4ae1ab..5d8dc5efec 100644
>     > --- a/drivers/gpu/drm/tiny/bochs.c
>     > +++ b/drivers/gpu/drm/tiny/bochs.c
>     > @@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev
>     *pdev, const struct pci_device_id *ent
>     >
>     >       ret = pcim_enable_device(pdev);
>     >       if (ret)
>     > -             goto err_free_dev;
>     > +             return ret;
>     >
>     >       pci_set_drvdata(pdev, dev);
>     >
>     >       ret = bochs_load(bochs);
>     >       if (ret)
>     > -             goto err_free_dev;
>     > +             return ret;
>     >
>     >       ret = drm_dev_register(dev, 0);
>     >       if (ret)
>     > -             goto err_free_dev;
>     > +             return ret;
>     >
>     >       drm_client_setup(dev, NULL);
>     >
>     >       return ret;
>     > -
>     > -err_free_dev:
>     > -     drm_dev_put(dev);
>     > -     return ret;
>     >   }
>     >
>     >   static void bochs_pci_remove(struct pci_dev *pdev) >
>     --
>     --
>     Thomas Zimmermann
>     Graphics Driver Developer
>     SUSE Software Solutions Germany GmbH
>     Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
<http://www.suse.com>
>     <http://www.suse.com>
>     GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG
>     Nürnberg)
>
>

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
<http://www.suse.com>
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#6 lore raw

Hi Thomas,

You are right. I got confused and sent the wrong reply. Sorry for the noise.

Thanks,
Myeonghun

2026년 5월 4일 (월) 오후 5:36, Thomas Zimmermann <[email protected]>님이 작성:

Quoted 186 lines

Hi

Am 30.04.26 um 15:52 schrieb Myeonghun Pak:

Quoted 11 lines

Thanks for the explanation.

I see your point now. My patch treated uart_add_one_port() failure as a fatal
probe failure, but the current code is intentionally trying to keep the driver
alive so that other MAX3100 ports can still be available even if one port cannot
be instantiated.

Please drop this patch. I will not pursue this direction.

Why? The was patch was good AFAICT. It's just missing a Fixes tag.

Best regards
Thomas

Quoted 16 lines

Thanks,
Myeonghun

2026년 4월 24일 (금) 오후 11:59, Thomas Zimmermann
<[email protected]>님이 작성:

Hi

Am 24.04.26 um 15:40 schrieb Myeonghun Pak:
> Hi Thomas,
>
> Thank you for your reply. I will ensure that the requested |Fixes| tag
> and |stable| CC are included in the next patch I send. >

Quoted 8 lines

> Regarding your request for information about AI usage and how the > issue was identified:
>
> * This issue was identified during our ongoing static-analysis
> research while reviewing kernel code.
> 1
>
<

https://mail.google.com/mail/u/0/#all/%23thread-f:1863355320119932959>

Quoted 40 lines
Quoted 1 line

* Specifically, it was found by an experimental static

analysis tool
> that we are currently developing. The tool is not public
yet, so I
> prefer not to disclose further project details at this stage.
>
> * AI was used only for cross-review, not as the primary means of
> finding or fixing the bug.
> * I manually reviewed the code and verified the issue before
sending
> the patch.
>
> I will incorporate your requests and this additional context, and then
> resend the modified patch.

Thanks a lot.

Best regards
Thomas

>
> Thank you.
>
> Myeonghun Pak
>
>
> 2026년 4월 24일 (금) 오후 10:25, Thomas Zimmermann > <[email protected]>님이 작성:
>
> Hi,
>
> please add fixes tags to all these patches you're sending. You
> also need
> to CC stable so that they can be backported easily. Also
list the AI
> you're using to find and create these patches.
>

Quoted 7 lines

> Best regards
> Thomas
>
> Am 24.04.26 um 14:34 schrieb Myeonghun Pak:
> > bochs_pci_probe() allocates the DRM device with
> devm_drm_dev_alloc(),
> > which registers a devres action to drop the initial DRM

device

Quoted 71 lines
Quoted 4 lines

reference
> on driver detach or probe failure.
>
> The error path currently calls drm_dev_put() manually. If

    probe then
    >     > returns an error, devres will run the registered release
    action
    >     and put
    >     > the same device again, after the first put may already have
    >     released it.
    >     >
    >     > Return the probe error directly and let devres own the
    final put.
    >     >
    >     > Signed-off-by: Myeonghun Pak <[email protected]>
    >     > ---
    >     >   drivers/gpu/drm/tiny/bochs.c | 10 +++-------
    >     >   1 file changed, 3 insertions(+), 7 deletions(-)
    >     >
    >     > diff --git a/drivers/gpu/drm/tiny/bochs.c
    >     b/drivers/gpu/drm/tiny/bochs.c
    >     > index 222e4ae1ab..5d8dc5efec 100644
    >     > --- a/drivers/gpu/drm/tiny/bochs.c
    >     > +++ b/drivers/gpu/drm/tiny/bochs.c
    >     > @@ -761,25 +761,21 @@ static int bochs_pci_probe(struct
    pci_dev
    >     *pdev, const struct pci_device_id *ent
    >     >
    >     >       ret = pcim_enable_device(pdev);
    >     >       if (ret)
    >     > -             goto err_free_dev;
    >     > +             return ret;
    >     >
    >     >       pci_set_drvdata(pdev, dev);
    >     >
    >     >       ret = bochs_load(bochs);
    >     >       if (ret)
    >     > -             goto err_free_dev;
    >     > +             return ret;
    >     >
    >     >       ret = drm_dev_register(dev, 0);
    >     >       if (ret)
    >     > -             goto err_free_dev;
    >     > +             return ret;
    >     >
    >     >       drm_client_setup(dev, NULL);
    >     >
    >     >       return ret;
    >     > -
    >     > -err_free_dev:
    >     > -     drm_dev_put(dev);
    >     > -     return ret;
    >     >   }
    >     >
    >     >   static void bochs_pci_remove(struct pci_dev *pdev)
    >
    >     --
    >     --
    >     Thomas Zimmermann
    >     Graphics Driver Developer
    >     SUSE Software Solutions Germany GmbH
    >     Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
    <http://www.suse.com>
    >     <http://www.suse.com>
    >     GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB
    36809, AG
    >     Nürnberg)
    >
    >

    --
Quoted 10 lines
    --
    Thomas Zimmermann
    Graphics Driver Developer
    SUSE Software Solutions Germany GmbH
    Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
    <http://www.suse.com>
    GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG
    Nürnberg)

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

#7 lore raw
In reply to Myeonghun Pak

Am 24.04.26 um 14:34 schrieb Myeonghun Pak:

Quoted 11 lines

bochs_pci_probe() allocates the DRM device with devm_drm_dev_alloc(), which registers a devres action to drop the initial DRM device reference on driver detach or probe failure.

The error path currently calls drm_dev_put() manually. If probe then returns an error, devres will run the registered release action and put the same device again, after the first put may already have released it.

Return the probe error directly and let devres own the final put.

Fixes 04826f588682 ("drm/bochs: Allocate DRM device in struct bochs_device")
Cc Thomas Zimmermann <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc <[email protected]> # v6.13+
Quoted 37 lines
---
  drivers/gpu/drm/tiny/bochs.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/tiny/bochs.c +3 -7
index 222e4ae1ab..5d8dc5efec 100644
@@ -761,25 +761,21 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
 
  	ret = pcim_enable_device(pdev);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	pci_set_drvdata(pdev, dev);
 
  	ret = bochs_load(bochs);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	ret = drm_dev_register(dev, 0);
  	if (ret)
-		goto err_free_dev;
+		return ret;
 
  	drm_client_setup(dev, NULL);
 
  	return ret;
-
-err_free_dev:
-	drm_dev_put(dev);
-	return ret;
  }
 
  static void bochs_pci_remove(struct pci_dev *pdev)
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#9 lore raw

Hi Markus,

Thanks for the pointer. I will keep the Fixes tag on a single line in future submissions.

Best regards,
Myeonghun Pak

2026년 5월 8일 (금) 오후 4:43, Markus Elfring <[email protected]>님이 작성:

Quoted 14 lines

…

Quoted 1 line
Quoted 1 line

Return the probe error directly and let devres own the final put.

…

Quoted 2 lines
Fixes 04826f588682 ("drm/bochs: Allocate DRM device in struct

bochs_device")

…

See also once more:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.1-rc2#n145

Regards,
Markus