Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1267238 > unrolled thread

[PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev

Started byColin King <colin.king@canonical.com>
First post2015-11-11 16:10 +0100
Last post2015-11-11 16:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev Colin King <colin.king@canonical.com> - 2015-11-11 16:10 +0100
    Re: [PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null  dev Antti Palosaari <crope@iki.fi> - 2015-11-11 16:50 +0100

#1267238 — [PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev

FromColin King <colin.king@canonical.com>
Date2015-11-11 16:10 +0100
Subject[PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev
Message-ID<qtFc5-4pw-3@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Static analysis with smatch detected a couple of issues:

drivers/media/usb/hackrf/hackrf.c:1533 hackrf_probe()
  error: we previously assumed 'dev' could be null (see line 1366)
drivers/media/usb/hackrf/hackrf.c:1533 hackrf_probe()
  error: dereferencing freed memory 'dev'

A dev_dbg message is being output on a kfree'd dev.  Worse, if dev
is not allocated earlier, on, a null pointer deference on dev->dev
can occur onthe deb_dbg call.  Clean this up by only printing a debug
message if dev is not null and has not been kfree'd.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/usb/hackrf/hackrf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index e05bfec..faf3670 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -1528,9 +1528,9 @@ err_v4l2_ctrl_handler_free_tx:
 err_v4l2_ctrl_handler_free_rx:
 	v4l2_ctrl_handler_free(&dev->rx_ctrl_handler);
 err_kfree:
+	dev_dbg(dev->dev, "failed=%d\n", ret);
 	kfree(dev);
 err:
-	dev_dbg(dev->dev, "failed=%d\n", ret);
 	return ret;
 }
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1267258 — Re: [PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev

FromAntti Palosaari <crope@iki.fi>
Date2015-11-11 16:50 +0100
SubjectRe: [PATCH] [media] hackrf: don't emit dev debug on a kfree'd or null dev
Message-ID<qtFOO-4EQ-25@gated-at.bofh.it>
In reply to#1267238
On 11/11/2015 05:05 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Static analysis with smatch detected a couple of issues:
>
> drivers/media/usb/hackrf/hackrf.c:1533 hackrf_probe()
>    error: we previously assumed 'dev' could be null (see line 1366)
> drivers/media/usb/hackrf/hackrf.c:1533 hackrf_probe()
>    error: dereferencing freed memory 'dev'
>
> A dev_dbg message is being output on a kfree'd dev.  Worse, if dev
> is not allocated earlier, on, a null pointer deference on dev->dev
> can occur onthe deb_dbg call.  Clean this up by only printing a debug
> message if dev is not null and has not been kfree'd.

It is already fixed:
https://patchwork.linuxtv.org/patch/31712/

>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/media/usb/hackrf/hackrf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
> index e05bfec..faf3670 100644
> --- a/drivers/media/usb/hackrf/hackrf.c
> +++ b/drivers/media/usb/hackrf/hackrf.c
> @@ -1528,9 +1528,9 @@ err_v4l2_ctrl_handler_free_tx:
>   err_v4l2_ctrl_handler_free_rx:
>   	v4l2_ctrl_handler_free(&dev->rx_ctrl_handler);
>   err_kfree:
> +	dev_dbg(dev->dev, "failed=%d\n", ret);
>   	kfree(dev);
>   err:
> -	dev_dbg(dev->dev, "failed=%d\n", ret);
>   	return ret;
>   }
>
>

regards
Antti




-- 
http://palosaari.fi/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web