media: au0828: Convert BUG_ON to WARN_ONCE

Message ID 1333927151-13014-1-git-send-email-Larry.Finger@lwfinger.net (mailing list archive)
State Rejected, archived
Headers

Commit Message

Larry Finger April 8, 2012, 11:19 p.m. UTC
  In the mail thread at http://www.mythtv.org/pipermail/mythtv-users/2012-April/331164.html,
a kernel crash is triggered when trying to run mythtv with a HVR950Q tuner.
The crash condition is due to res_free() being called to free something that
has is not reserved. The actual reason for this mismatch of reserve/free is
not known; however, using a BUG_ON rather than a WARN_ON seems unfortunate.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/media/video/au0828/au0828-video.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Devin Heitmueller April 9, 2012, 1:46 a.m. UTC | #1
On Sun, Apr 8, 2012 at 7:19 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> In the mail thread at http://www.mythtv.org/pipermail/mythtv-users/2012-April/331164.html,
> a kernel crash is triggered when trying to run mythtv with a HVR950Q tuner.
> The crash condition is due to res_free() being called to free something that
> has is not reserved. The actual reason for this mismatch of reserve/free is
> not known; however, using a BUG_ON rather than a WARN_ON seems unfortunate.

This patch should be nack'd.  The real reason should be identified,
and a patch should be submitted for that (and from what I gather, it
seems like it is easily reproduced by the submitter).  Just add a few
"dump_stack()" calls in the res_get() and res_free() calls to identify
the failing call path.

Devin
  
Larry Finger April 9, 2012, 2:16 a.m. UTC | #2
On 04/08/2012 08:46 PM, Devin Heitmueller wrote:
> On Sun, Apr 8, 2012 at 7:19 PM, Larry Finger<Larry.Finger@lwfinger.net>  wrote:
>> In the mail thread at http://www.mythtv.org/pipermail/mythtv-users/2012-April/331164.html,
>> a kernel crash is triggered when trying to run mythtv with a HVR950Q tuner.
>> The crash condition is due to res_free() being called to free something that
>> has is not reserved. The actual reason for this mismatch of reserve/free is
>> not known; however, using a BUG_ON rather than a WARN_ON seems unfortunate.
>
> This patch should be nack'd.  The real reason should be identified,
> and a patch should be submitted for that (and from what I gather, it
> seems like it is easily reproduced by the submitter).  Just add a few
> "dump_stack()" calls in the res_get() and res_free() calls to identify
> the failing call path.

I agree that we need to find the real cause; however, I am not the one with the 
problem, and I do not have the hardware. In addition, I am not sure how much 
additional debug information the person will be able to provide. He has not 
built Linux kernels since 1.2. If he can get a kernel built, then we will try to 
find the real cause.

In any case, why the reluctance to get rid of the BUG_ON? Is this condition so 
severe that the kernel needs to be stopped immediately?

Larry
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
index 0b3e481..5c53e38 100644
--- a/drivers/media/video/au0828/au0828-video.c
+++ b/drivers/media/video/au0828/au0828-video.c
@@ -891,8 +891,13 @@  static int res_locked(struct au0828_dev *dev, unsigned int bit)
 static void res_free(struct au0828_fh *fh, unsigned int bits)
 {
 	struct au0828_dev    *dev = fh->dev;
+	unsigned int bits2 = fh->resources & bits;
 
-	BUG_ON((fh->resources & bits) != bits);
+	if (bits2 != bits) {
+		WARN_ONCE(true, "au0828: Trying to free resource 0x%x"
+			  " without reserving it\n", bits);
+		return;
+	}
 
 	mutex_lock(&dev->lock);
 	fh->resources  &= ~bits;