lkml.org 
[lkml]   [2022]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net] ice: Add check for kzalloc
Wed, Dec 07, 2022 at 03:20:00AM CET, jiasheng@iscas.ac.cn wrote:
>On Tue, Dec 06, 2022 at 05:47:01PM +0800, Jiri Pirko wrote:
>>>As kzalloc may fail and return NULL pointer,
>>>it should be better to check the return value
>>>in order to avoid the NULL pointer dereference.
>>
>> Okay, so? Be imperative to the code base, tell it what to do in your
>> patch description.
>
>OK, I will describe the changes by the patch in more details.

It is not about details, it is about "imperative mood".


>
>>>@@ -462,6 +462,17 @@ static struct tty_driver *ice_gnss_create_tty_driver(struct ice_pf *pf)
>>> GFP_KERNEL);
>>> pf->gnss_serial[i] = NULL;
>>>
>>>+ if (!pf->gnss_tty_port[i]) {
>>>+ for (j = 0; j < i; j++) {
>>>+ tty_port_destroy(pf->gnss_tty_port[j]);
>>
>> You are destroying port which you didn't call (pf->gnss_tty_port[i])
>> for. Also, you are introducing a code duplication here with the error
>> path couple of lines below. Please convert this to goto-label error
>> path so the cleanup code is shared.
>
>I will convert this to goto-label in v2.
>But I have a question that the j is from 0 to (i - 1), and therefore only
>the initialized port will be destroyed.
>Is there any wrong?

You are right.

>
>Thanks,
>Jiang
>

\
 
 \ /
  Last update: 2022-12-07 14:42    [W:0.035 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site