Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kolga@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [bug report] NFSD introduce async copy feature
Date: Wed, 4 Dec 2019 11:00:08 +0300
Message-ID: <20191204080008.gj7zignrwudryzhd@kili.mountain> (raw)

Hello Olga Kornievskaia,

The patch e0639dc5805a: "NFSD introduce async copy feature" from Jul
20, 2018, leads to the following static checker warning:

	fs/nfsd/nfs4proc.c:1494 nfsd4_do_async_copy()
	error: we previously assumed 'copy->nf_src' could be null (see line 1464)

fs/nfsd/nfs4proc.c
  1460          struct nfsd4_copy *cb_copy;
  1461  
  1462          if (!copy->cp_intra) { /* Inter server SSC */
  1463                  copy->nf_src = kzalloc(sizeof(struct nfsd_file), GFP_KERNEL);
  1464                  if (!copy->nf_src) {
                             ^^^^^^^^^^^^
Check for NULL (allocation failure).

  1465                          copy->nfserr = nfserr_serverfault;
  1466                          nfsd4_interssc_disconnect(copy->ss_mnt);
  1467                          goto do_callback;
  1468                  }
  1469                  copy->nf_src->nf_file = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
  1470                                                &copy->stateid);
  1471                  if (IS_ERR(copy->nf_src->nf_file)) {
  1472                          kfree(copy->nf_src);
  1473                          copy->nfserr = nfserr_offload_denied;
  1474                          nfsd4_interssc_disconnect(copy->ss_mnt);
  1475                          goto do_callback;
  1476                  }
  1477          }
  1478  
  1479          copy->nfserr = nfsd4_do_copy(copy, 0);
  1480  do_callback:
  1481          cb_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
  1482          if (!cb_copy)
  1483                  goto out;
  1484          memcpy(&cb_copy->cp_res, &copy->cp_res, sizeof(copy->cp_res));
  1485          cb_copy->cp_clp = copy->cp_clp;
  1486          cb_copy->nfserr = copy->nfserr;
  1487          memcpy(&cb_copy->fh, &copy->fh, sizeof(copy->fh));
  1488          nfsd4_init_cb(&cb_copy->cp_cb, cb_copy->cp_clp,
  1489                          &nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD);
  1490          nfsd4_run_cb(&cb_copy->cp_cb);
  1491  out:
  1492          if (!copy->cp_intra)
  1493                  kfree(copy->nf_src);
                              ^^^^^^^^^^^^
  1494          cleanup_async_copy(copy);
                                   ^^^^
copy->nf_src can be NULL or it can be freed so this cleanup function
is going to crash.

  1495          return 0;
  1496  }

regards,
dan carpenter

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04  8:00 Dan Carpenter [this message]
2019-12-04  8:00 Dan Carpenter

Reply instructions:

You may reply publically 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=20191204080008.gj7zignrwudryzhd@kili.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@vger.kernel.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

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git