All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] bus: mhi: ep: Do not allocate event ring element on stack
@ 2023-10-20 13:54 Dan Carpenter
  2023-10-25  7:58 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-10-20 13:54 UTC (permalink / raw)
  To: mani; +Cc: mhi

Hello Manivannan Sadhasivam,

The patch b910ee376ab3: "bus: mhi: ep: Do not allocate event ring
element on stack" from Sep 1, 2023 (linux-next), leads to the
following Smatch static checker warning:

drivers/bus/mhi/ep/main.c:106 mhi_ep_send_ee_event() error: potential null dereference 'event'.  (kzalloc returns null)
drivers/bus/mhi/ep/main.c:121 mhi_ep_send_cmd_comp_event() error: potential null dereference 'event'.  (kzalloc returns null)
drivers/bus/mhi/ep/main.c:77 mhi_ep_send_completion_event() error: potential null dereference 'event'.  (kzalloc returns null)
drivers/bus/mhi/ep/main.c:92 mhi_ep_send_state_change_event() error: potential null dereference 'event'.  (kzalloc returns null)

drivers/bus/mhi/ep/main.c
    101 int mhi_ep_send_ee_event(struct mhi_ep_cntrl *mhi_cntrl, enum mhi_ee_type exec_env)
    102 {
    103         struct mhi_ring_element *event = kzalloc(sizeof(struct mhi_ring_element), GFP_KERNEL);

No checks for NULL.  Some people have a rule that functions which can
fail should not be in the declaration block.  From a static analysis
perspective code in the declaration block is buggier than code in the
code area.

    104         int ret;
    105 
--> 106         event->dword[0] = MHI_EE_EV_DWORD0(exec_env);
    107         event->dword[1] = MHI_SC_EV_DWORD1(MHI_PKT_TYPE_EE_EVENT);
    108 
    109         ret = mhi_ep_send_event(mhi_cntrl, 0, event, 0);
    110         kfree(event);
    111 
    112         return ret;
    113 }

regards,
dan carpenter

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

end of thread, other threads:[~2023-10-25  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 13:54 [bug report] bus: mhi: ep: Do not allocate event ring element on stack Dan Carpenter
2023-10-25  7:58 ` Manivannan Sadhasivam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.