linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: Fix null pointer dereference
@ 2018-08-24  4:07 Ding Xiang
  2018-08-24  6:29 ` Johan Hovold
  2018-08-24 10:27 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Ding Xiang @ 2018-08-24  4:07 UTC (permalink / raw)
  To: johan, elder, gregkh, greybus-dev, devel, linux-kernel

If fw is null then fw->size will trigger null pointer dereference

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
---
 drivers/staging/greybus/bootrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
index e85ffae..3af28a0 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
 
 queue_work:
 	/* Refresh timeout */
-	if (!ret && (offset + size == fw->size))
+	if (!ret && fw && (offset + size == fw->size))
 		next_request = NEXT_REQ_READY_TO_BOOT;
 	else
 		next_request = NEXT_REQ_GET_FIRMWARE;
-- 
1.8.3.1




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

* Re: [PATCH] staging: greybus: Fix null pointer dereference
  2018-08-24  4:07 [PATCH] staging: greybus: Fix null pointer dereference Ding Xiang
@ 2018-08-24  6:29 ` Johan Hovold
  2018-08-24 10:08   ` Ding Xiang
  2018-08-24 10:27 ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2018-08-24  6:29 UTC (permalink / raw)
  To: Ding Xiang
  Cc: johan, elder, gregkh, greybus-dev, devel, linux-kernel, Viresh Kumar

On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:
> If fw is null then fw->size will trigger null pointer dereference
>
> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
> ---
>  drivers/staging/greybus/bootrom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
> index e85ffae..3af28a0 100644
> --- a/drivers/staging/greybus/bootrom.c
> +++ b/drivers/staging/greybus/bootrom.c
> @@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
>  
>  queue_work:
>  	/* Refresh timeout */
> -	if (!ret && (offset + size == fw->size))
> +	if (!ret && fw && (offset + size == fw->size))
>  		next_request = NEXT_REQ_READY_TO_BOOT;
>  	else
>  		next_request = NEXT_REQ_GET_FIRMWARE;

How could fw be NULL when ret is 0 here?

It may not be as obvious as one might have wished, but the current code
looks correct to me.

Johan

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

* Re: [PATCH] staging: greybus: Fix null pointer dereference
  2018-08-24  6:29 ` Johan Hovold
@ 2018-08-24 10:08   ` Ding Xiang
  0 siblings, 0 replies; 4+ messages in thread
From: Ding Xiang @ 2018-08-24 10:08 UTC (permalink / raw)
  To: Johan Hovold
  Cc: elder, gregkh, greybus-dev, devel, linux-kernel, Viresh Kumar

Hi, Johan

     sorry, it's my fault.


On 8/24/2018 2:29 PM, Johan Hovold wrote:
> On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:
>> If fw is null then fw->size will trigger null pointer dereference
>>
>> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
>> ---
>>   drivers/staging/greybus/bootrom.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
>> index e85ffae..3af28a0 100644
>> --- a/drivers/staging/greybus/bootrom.c
>> +++ b/drivers/staging/greybus/bootrom.c
>> @@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
>>   
>>   queue_work:
>>   	/* Refresh timeout */
>> -	if (!ret && (offset + size == fw->size))
>> +	if (!ret && fw && (offset + size == fw->size))
>>   		next_request = NEXT_REQ_READY_TO_BOOT;
>>   	else
>>   		next_request = NEXT_REQ_GET_FIRMWARE;
> How could fw be NULL when ret is 0 here?
>
> It may not be as obvious as one might have wished, but the current code
> looks correct to me.
>
> Johan
>





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

* Re: [PATCH] staging: greybus: Fix null pointer dereference
  2018-08-24  4:07 [PATCH] staging: greybus: Fix null pointer dereference Ding Xiang
  2018-08-24  6:29 ` Johan Hovold
@ 2018-08-24 10:27 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-08-24 10:27 UTC (permalink / raw)
  To: Ding Xiang; +Cc: johan, elder, gregkh, greybus-dev, devel, linux-kernel

On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:
> If fw is null then fw->size will trigger null pointer dereference
> 
> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
> ---
>  drivers/staging/greybus/bootrom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
> index e85ffae..3af28a0 100644
> --- a/drivers/staging/greybus/bootrom.c
> +++ b/drivers/staging/greybus/bootrom.c
> @@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
>  
>  queue_work:
>  	/* Refresh timeout */
> -	if (!ret && (offset + size == fw->size))
> +	if (!ret && fw && (offset + size == fw->size))

That is impossible.  If "ret" is zero that implies "fw" is a valid
pointer.

regards,
dan carpenter


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

end of thread, other threads:[~2018-08-24 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24  4:07 [PATCH] staging: greybus: Fix null pointer dereference Ding Xiang
2018-08-24  6:29 ` Johan Hovold
2018-08-24 10:08   ` Ding Xiang
2018-08-24 10:27 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).