oe-kbuild-all.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev
Subject: [goldwynr:iomap.2 3/32] fs/iomap/buffered-io.c:426 iomap_read_encoded() error: we previously assumed 'ctx->ops' could be null (see line 395)
Date: Wed, 15 May 2024 11:12:38 +0200	[thread overview]
Message-ID: <fb3910cc-2691-488b-823b-7ebcb0b31a64@suswa.mountain> (raw)

tree:   https://github.com/goldwynr/linux iomap.2
head:   7defcedce6c031c95fa753060462301bd623163f
commit: 1bc69b67cc4890a9f5afb4ac4f3ba3f14fb287da [3/32] iomap: Introduce IOMAP_ENCODED
config: xtensa-randconfig-r071-20240514 (https://download.01.org/0day-ci/archive/20240515/202405150541.8zhPcUkQ-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202405150541.8zhPcUkQ-lkp@intel.com/

New smatch warnings:
fs/iomap/buffered-io.c:426 iomap_read_encoded() error: we previously assumed 'ctx->ops' could be null (see line 395)

vim +426 fs/iomap/buffered-io.c

1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  373  static loff_t
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  374  iomap_read_encoded(const struct iomap_iter *iter, struct iomap_readpage_ctx *ctx)
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  375  {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  376  	struct folio *folio;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  377  	const struct iomap *iomap = &iter->iomap;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  378  	struct address_space *mapping = iter->inode->i_mapping;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  379  	pgoff_t index = iomap->offset >> PAGE_SHIFT;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  380  	pgoff_t end_index = (iomap->offset + iomap->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  381  	pgoff_t ra_index = -1, ra_end_index = 0;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  382  	gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  383  	struct bio *bio;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  384  	struct bio_set *bioset;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  385  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  386  	WARN_ON(ctx->cur_folio && (ctx->cur_folio->index > end_index ||
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  387  			ctx->cur_folio->index < index));
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  388  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  389  	/* If there is already a bio in progress, submit it first */
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  390  	if (ctx->bio) {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  391  		ctx->ops->submit_io(iter->inode, ctx->bio, iter->pos, false);
                                                                ^^^^^^^^^^
Unchecked dereference

1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  392  		ctx->bio = NULL;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  393  	}
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  394  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31 @395  	if (ctx->ops && ctx->ops->bio_set)
                                                            ^^^^^^^^
Check for NULL.  Is this necessary?

1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  396  		bioset = ctx->ops->bio_set;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  397  	else
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  398  		bioset = &fs_bio_set;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  399  	bio = bio_alloc_bioset(iomap->bdev, end_index - index + 1,
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  400  			REQ_OP_READ, gfp, bioset);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  401  	bio->bi_iter.bi_sector = iomap_sector(iomap, iomap->offset);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  402  	bio->bi_end_io = iomap_read_end_io;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  403  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  404  	if (ctx->rac) {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  405  		ra_index = readahead_index(ctx->rac);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  406  		ra_end_index = ra_index + readahead_count(ctx->rac);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  407  	}
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  408  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  409  	while (index < end_index) {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  410  		if (ctx->cur_folio && index == ctx->cur_folio->index) {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  411  			folio = ctx->cur_folio;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  412  			ctx->cur_folio = NULL;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  413  			ctx->cur_folio_in_bio = true;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  414  		} else if (index >= ra_index && index < ra_end_index) {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  415  			do {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  416  				folio = readahead_folio(ctx->rac);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  417  			} while (folio->index < index);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  418  			ra_index = readahead_index(ctx->rac);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  419  		} else {
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  420  			folio = filemap_grab_folio(mapping, index);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  421  		}
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  422  		bio_add_folio_nofail(bio, folio, folio_size(folio), 0);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  423  		index++;
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  424  	}
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  425  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31 @426  	ctx->ops->submit_io(iter->inode, bio, iomap->offset, true);
                                                        ^^^^^^^^^^
Unchecked dereference

1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  427  
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  428  	return iomap->length - (iter->pos - iomap->offset);
1bc69b67cc4890 Goldwyn Rodrigues 2023-01-31  429  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


                 reply	other threads:[~2024-05-15  9:12 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=fb3910cc-2691-488b-823b-7ebcb0b31a64@suswa.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=rgoldwyn@suse.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).