From patchwork Mon Sep 19 16:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 12980673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16EDDC54EE9 for ; Mon, 19 Sep 2022 15:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiISPvR (ORCPT ); Mon, 19 Sep 2022 11:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbiISPvQ (ORCPT ); Mon, 19 Sep 2022 11:51:16 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 039393A48A; Mon, 19 Sep 2022 08:51:15 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4MWTcq5tMjzKQ1L; Mon, 19 Sep 2022 23:49:15 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.102.38]) by APP1 (Coremail) with SMTP id cCh0CgA3vC_wjyhjr7ohBA--.1512S4; Mon, 19 Sep 2022 23:51:13 +0800 (CST) From: Wei Yongjun To: Haimin Zhang , Alexander Aring , Stefan Schmidt , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Wei Yongjun , linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] net: ieee802154: fix error return code in dgram_bind() Date: Mon, 19 Sep 2022 16:08:30 +0000 Message-Id: <20220919160830.1436109-1-weiyongjun@huaweicloud.com> X-Mailer: git-send-email 2.34.1 MIME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nxnUUI43ZEXa7IU1Za93UUUUU== X-CM-SenderInfo: 5zhl50pqjm3046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org From: Wei Yongjun Fix to return error code -EINVAL from the error handling case instead of 0, as done elsewhere in this function. Fixes: 94160108a70c ("net/ieee802154: fix uninit value bug in dgram_sendmsg") Signed-off-by: Wei Yongjun --- net/ieee802154/socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c index 7889e1ef7fad..35c54dce74f9 100644 --- a/net/ieee802154/socket.c +++ b/net/ieee802154/socket.c @@ -498,8 +498,10 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len) if (err < 0) goto out; - if (addr->family != AF_IEEE802154) + if (addr->family != AF_IEEE802154) { + err = -EINVAL; goto out; + } ieee802154_addr_from_sa(&haddr, &addr->addr); dev = ieee802154_get_dev(sock_net(sk), &haddr);