public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers:misc: ti-st: fix potential NULL pointer dereference in st_register()
@ 2012-10-08  0:41 Wei Yongjun
  2012-10-08  0:46 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-10-08  0:41 UTC (permalink / raw)
  To: gregkh; +Cc: yongjun_wei, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

The dereference should be moved below the NULL test.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/misc/ti-st/st_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 46937b1..ee341ea 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -511,13 +511,14 @@ long st_register(struct st_proto_s *new_proto)
 	unsigned long flags = 0;
 
 	st_kim_ref(&st_gdata, 0);
-	pr_info("%s(%d) ", __func__, new_proto->chnl_id);
 	if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
 	    || new_proto->reg_complete_cb == NULL) {
 		pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
 		return -EINVAL;
 	}
 
+	pr_info("%s(%d) ", __func__, new_proto->chnl_id);
+
 	if (new_proto->chnl_id >= ST_MAX_CHANNELS) {
 		pr_err("chnl_id %d not supported", new_proto->chnl_id);
 		return -EPROTONOSUPPORT;


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

* Re: [PATCH] drivers:misc: ti-st: fix potential NULL pointer dereference in st_register()
  2012-10-08  0:41 [PATCH] drivers:misc: ti-st: fix potential NULL pointer dereference in st_register() Wei Yongjun
@ 2012-10-08  0:46 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2012-10-08  0:46 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: yongjun_wei, linux-kernel

On Mon, Oct 08, 2012 at 08:41:36AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> The dereference should be moved below the NULL test.
> 
> dpatch engine is used to auto generate this patch.
> (https://github.com/weiyj/dpatch)
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>  drivers/misc/ti-st/st_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
> index 46937b1..ee341ea 100644
> --- a/drivers/misc/ti-st/st_core.c
> +++ b/drivers/misc/ti-st/st_core.c
> @@ -511,13 +511,14 @@ long st_register(struct st_proto_s *new_proto)
>  	unsigned long flags = 0;
>  
>  	st_kim_ref(&st_gdata, 0);
> -	pr_info("%s(%d) ", __func__, new_proto->chnl_id);
>  	if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
>  	    || new_proto->reg_complete_cb == NULL) {
>  		pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
>  		return -EINVAL;
>  	}
>  
> +	pr_info("%s(%d) ", __func__, new_proto->chnl_id);

Why print this at all?  Can't you just drop it now?

greg k-h

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

end of thread, other threads:[~2012-10-08  0:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08  0:41 [PATCH] drivers:misc: ti-st: fix potential NULL pointer dereference in st_register() Wei Yongjun
2012-10-08  0:46 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox