diff mbox series

infiniband: cxgb4: cm: Check skb value

Message ID 20230904115925.261974-1-artem.chernyshev@red-soft.ru (mailing list archive)
State Superseded
Headers show
Series infiniband: cxgb4: cm: Check skb value | expand

Commit Message

Artem Chernyshev Sept. 4, 2023, 11:59 a.m. UTC
get_skb() can't allocate skb in case of OOM.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Krzysztof Kozlowski Sept. 4, 2023, 8:07 p.m. UTC | #1
On 04/09/2023 13:59, Artem Chernyshev wrote:
> get_skb() can't allocate skb in case of OOM.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
> ---
>  drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
> index ced615b5ea09..775da62b38ec 100644
> --- a/drivers/infiniband/hw/cxgb4/cm.c
> +++ b/drivers/infiniband/hw/cxgb4/cm.c
> @@ -1965,6 +1965,10 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
>  	int win;
>  
>  	skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
> +	if (!skb) {
> +		pr_err("%s - cannot alloc skb!\n", __func__);

I don't think we print memory allocation failures.

Best regards,
Krzysztof
Artem Chernyshev Sept. 5, 2023, 12:37 p.m. UTC | #2
On Mon, Sep 04, 2023 at 10:07:26PM +0200, Krzysztof Kozlowski wrote:
> On 04/09/2023 13:59, Artem Chernyshev wrote:
> > get_skb() can't allocate skb in case of OOM.
> > 
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> > 
> > Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
> > ---
> >  drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
> > index ced615b5ea09..775da62b38ec 100644
> > --- a/drivers/infiniband/hw/cxgb4/cm.c
> > +++ b/drivers/infiniband/hw/cxgb4/cm.c
> > @@ -1965,6 +1965,10 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
> >  	int win;
> >  
> >  	skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
> > +	if (!skb) {
> > +		pr_err("%s - cannot alloc skb!\n", __func__);
> 
> I don't think we print memory allocation failures.
> 
> Best regards,
> Krzysztof
> 

Sure, will fix that in v2

Thanks,
Artem
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index ced615b5ea09..775da62b38ec 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1965,6 +1965,10 @@  static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
 	int win;
 
 	skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
+	if (!skb) {
+		pr_err("%s - cannot alloc skb!\n", __func__);
+		return -ENOMEM;
+	}
 	req = __skb_put_zero(skb, sizeof(*req));
 	req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR));
 	req->len16_pkd = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req), 16)));