Messages in this thread | | | Date | Wed, 7 Dec 2022 14:41:14 +0100 | From | Jiri Pirko <> | Subject | Re: [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 >
| |