DPDK patches and discussions
 help / color / mirror / Atom feed
From: bugzilla@dpdk.org
To: dev@dpdk.org
Subject: [dpdk-dev] [Bug 777] Potential error(e.g., resource leak, deadlock) due to the unreleased lock pdata->i2c_mutex
Date: Wed, 04 Aug 2021 17:03:27 +0000	[thread overview]
Message-ID: <bug-777-3@http.bugs.dpdk.org/> (raw)

https://bugs.dpdk.org/show_bug.cgi?id=777

            Bug ID: 777
           Summary: Potential error(e.g., resource leak, deadlock) due to
                    the unreleased lock pdata->i2c_mutex
           Product: DPDK
           Version: 20.11
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: ethdev
          Assignee: dev@dpdk.org
          Reporter: dg573847474@gmail.com
  Target Milestone: ---

source:
drivers/net/axgbe/axgbe_i2c.c

Hi, developers, thank you for your checking. The lock &pdata->i2c_mutex may not
be correctly released if the ret==1 and control flow goes to these two branches
listed below. Finally, the method returns with the unreleased lock. The fix is
to insert pthread_mutex_unlock(&pdata->i2c_mutex); before returning.


static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
{
        ...;
        pthread_mutex_lock(&pdata->i2c_mutex);
        ret = axgbe_i2c_disable(pdata);
        if (ret) {
                PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
                return ret; // the method returns with unreleased lock
        }

        ...;
        ret = axgbe_i2c_enable(pdata);
        if (ret) {
                PMD_DRV_LOG(ERR, "failed to enable i2c master\n");
                return ret; // the method returns with unreleased lock
        }

        ...;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

                 reply	other threads:[~2021-08-04 17:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-777-3@http.bugs.dpdk.org/ \
    --to=bugzilla@dpdk.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).